Sunday, April 30, 2017

URI Solution - 1105 Sub-prime - Solution in C++ |Ad Hoc

URI Solution - 1105 Sub-prime - Solution in C++ |Ad Hoc

Main Link on URI - https://www.urionlinejudge.com.br/judge/en/problems/view/1105

URI Online Judge Solution  | Ad Hoc


Problem Name: URI Problem - Sub-prime
Problem Number : URI - 1105
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus

URI Solution 1105 Code in CPP:



#include <cstdio>
#include <vector>
using namespace std;

int main()
{
 int b, n, x, d, c, v;
 bool check;

 while(scanf("%i %i", &b, &n) && (b || n))
 {
  int reserva[23];
  check = false;

  for (int i = 1; i <= b; ++i)
  {
   scanf("%i", &x);
   reserva[i] = x;
  }

  for (int i = 1; i <= n; ++i)
  {
   scanf("%i %i %i", &d, &c, &v);
   reserva[d] -= v;
   reserva[c] += v;
  }

  for (int i = 1; i <= b; ++i)
  {
   if(reserva[i] < 0){
    check = true;
    break;
   }
  }

  if(check == true){
   puts("N");
  }else{
   puts("S");
  }
 }

 return 0;
}

1 comment:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.