Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define endl '\n'
- #define sz(x) int(x.size())
- #define all(x) x.begin(), x.end()
- int main() {
- ios_base::sync_with_stdio(0), cin.tie(0);
- int n, m;
- while (scanf("%d %d", &n, &m), n || m) {
- int dep[n + 1];
- for (int i = 1; i <= n; i++) scanf("%d", &dep[i]);
- while (m--) {
- int a, b, v;
- scanf("%d %d %d", &a, &b, &v);
- dep[a] -= v;
- dep[b] += v;
- }
- bool can = true;
- for (int i = 1; i <= n; i++) {
- can &= (dep[i] >= 0);
- }
- char s[4] = "NS";
- printf("%c\n", s[can]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement