-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSub Prime.cpp
33 lines (32 loc) · 852 Bytes
/
Sub Prime.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//Created by William Lacerda on 12/08/2016
//https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=2726
#include <bits/stdc++.h>
#define MAXN 1010
using namespace std;
int main(int argc, char const *argv[]) {
int B, N, d, c, v;
int money[22];
cin >>B >> N;
while (B != 0 || N != 0) {
for (int i = 1; i <= B; i++) {
cin >> money[i];
}
for (int i = 0; i < N; i++) {
cin >> d >> c >> v;
money[d]-=v;
money[c]+=v;
}
for (int i = 1; i <= B; i++) {
//cout << money[i] << " ";
if (money[i] <0) {
cout << 'N'<<endl;
break;
}
else if (i == B){
cout << 'S'<<endl;
}
}
cin >>B >> N;
}
return 0;
}