-
-
Save fredbr/c2a1e7f99c2c1c0ce2fb8891ef58c61f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
const int maxn = 1010; | |
int d[maxn]; | |
int main() | |
{ | |
ios_base::sync_with_stdio(false); | |
cin.tie(0); | |
int m, n; | |
cin >> m >> n; | |
int tot = 0; | |
for (int i = 0; i < m; i++) { | |
int a, b, v; | |
cin >> a >> v >> b; | |
tot += v; | |
d[a] -= v; | |
d[b] += v; | |
} | |
int ans = 0; | |
for (int i = 1; i <= n; i++) ans += abs(d[i]); | |
ans /= 2; | |
if (ans != tot) cout << "S" << "\n"; | |
else cout << "N" << "\n"; | |
cout << ans << "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment