# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
115047 | 2019-06-04T19:35:46 Z | luciocf | Tug of War (BOI15_tug) | C++14 | 117 ms | 920 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5+10; int l[maxn], r[maxn], s[maxn], grau[maxn]; bool mark[maxn]; int main(void) { int n, k; scanf("%d %d", &n, &k); for (int i = 1; i <= 2*n; i++) { scanf("%d %d %d", &l[i], &r[i], &s[i]); r[i] += n; grau[l[i]]++, grau[r[i]]++; } if (n > 10) { bool ok = 1; for (int i = 1; i <= 2*n; i++) if (!grau[i]) ok = 0; if (ok) printf("YES\n"); else printf("NO\n"); return 0; } bool ans = 0; for (int mask = 0; mask < (1<<(2*n)); mask++) { bool ok = 1; for (int i = 1; i <= 2*n; i++) mark[i] = 0; for (int i = 0; i < 2*n; i++) { if (mask&(1<<i)) { if (mark[r[i+1]]) ok = 0; else mark[r[i+1]] = 1; } else { if (mark[l[i+1]]) ok = 0; else mark[l[i+1]] = 1; } } if (!ok) continue; int sa = 0, sb = 0; for (int i = 0; i < 2*n; i++) { if (mask&(1<<i)) sb += s[i+1]; else sa += s[i+1]; } if (abs(sa-sb) <= k) { ans = 1; break; } } if (ans == 1) printf("YES\n"); else printf("NO\n"); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 117 ms | 384 KB | Output is correct |
2 | Correct | 7 ms | 384 KB | Output is correct |
3 | Correct | 101 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 117 ms | 504 KB | Output is correct |
6 | Correct | 97 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 33 ms | 384 KB | Output is correct |
9 | Correct | 7 ms | 512 KB | Output is correct |
10 | Correct | 105 ms | 476 KB | Output is correct |
11 | Correct | 6 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 14 ms | 384 KB | Output is correct |
14 | Correct | 7 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
16 | Correct | 113 ms | 384 KB | Output is correct |
17 | Correct | 14 ms | 384 KB | Output is correct |
18 | Correct | 6 ms | 384 KB | Output is correct |
19 | Correct | 4 ms | 384 KB | Output is correct |
20 | Correct | 19 ms | 512 KB | Output is correct |
21 | Correct | 103 ms | 416 KB | Output is correct |
22 | Correct | 93 ms | 504 KB | Output is correct |
23 | Correct | 100 ms | 384 KB | Output is correct |
24 | Correct | 6 ms | 384 KB | Output is correct |
25 | Correct | 106 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 117 ms | 384 KB | Output is correct |
2 | Correct | 7 ms | 384 KB | Output is correct |
3 | Correct | 101 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 117 ms | 504 KB | Output is correct |
6 | Correct | 97 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 33 ms | 384 KB | Output is correct |
9 | Correct | 7 ms | 512 KB | Output is correct |
10 | Correct | 105 ms | 476 KB | Output is correct |
11 | Correct | 6 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 14 ms | 384 KB | Output is correct |
14 | Correct | 7 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
16 | Correct | 113 ms | 384 KB | Output is correct |
17 | Correct | 14 ms | 384 KB | Output is correct |
18 | Correct | 6 ms | 384 KB | Output is correct |
19 | Correct | 4 ms | 384 KB | Output is correct |
20 | Correct | 19 ms | 512 KB | Output is correct |
21 | Correct | 103 ms | 416 KB | Output is correct |
22 | Correct | 93 ms | 504 KB | Output is correct |
23 | Correct | 100 ms | 384 KB | Output is correct |
24 | Correct | 6 ms | 384 KB | Output is correct |
25 | Correct | 106 ms | 384 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Incorrect | 3 ms | 384 KB | Output isn't correct |
28 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 896 KB | Output is correct |
2 | Correct | 8 ms | 896 KB | Output is correct |
3 | Correct | 8 ms | 768 KB | Output is correct |
4 | Correct | 8 ms | 896 KB | Output is correct |
5 | Correct | 8 ms | 896 KB | Output is correct |
6 | Correct | 8 ms | 896 KB | Output is correct |
7 | Correct | 7 ms | 896 KB | Output is correct |
8 | Correct | 8 ms | 896 KB | Output is correct |
9 | Correct | 8 ms | 896 KB | Output is correct |
10 | Correct | 8 ms | 896 KB | Output is correct |
11 | Correct | 8 ms | 896 KB | Output is correct |
12 | Correct | 8 ms | 920 KB | Output is correct |
13 | Correct | 8 ms | 896 KB | Output is correct |
14 | Correct | 8 ms | 896 KB | Output is correct |
15 | Correct | 8 ms | 896 KB | Output is correct |
16 | Correct | 8 ms | 896 KB | Output is correct |
17 | Correct | 8 ms | 896 KB | Output is correct |
18 | Correct | 7 ms | 896 KB | Output is correct |
19 | Correct | 8 ms | 896 KB | Output is correct |
20 | Correct | 8 ms | 896 KB | Output is correct |
21 | Correct | 8 ms | 896 KB | Output is correct |
22 | Correct | 8 ms | 896 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 117 ms | 384 KB | Output is correct |
2 | Correct | 7 ms | 384 KB | Output is correct |
3 | Correct | 101 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 117 ms | 504 KB | Output is correct |
6 | Correct | 97 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 33 ms | 384 KB | Output is correct |
9 | Correct | 7 ms | 512 KB | Output is correct |
10 | Correct | 105 ms | 476 KB | Output is correct |
11 | Correct | 6 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 14 ms | 384 KB | Output is correct |
14 | Correct | 7 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
16 | Correct | 113 ms | 384 KB | Output is correct |
17 | Correct | 14 ms | 384 KB | Output is correct |
18 | Correct | 6 ms | 384 KB | Output is correct |
19 | Correct | 4 ms | 384 KB | Output is correct |
20 | Correct | 19 ms | 512 KB | Output is correct |
21 | Correct | 103 ms | 416 KB | Output is correct |
22 | Correct | 93 ms | 504 KB | Output is correct |
23 | Correct | 100 ms | 384 KB | Output is correct |
24 | Correct | 6 ms | 384 KB | Output is correct |
25 | Correct | 106 ms | 384 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Incorrect | 3 ms | 384 KB | Output isn't correct |
28 | Halted | 0 ms | 0 KB | - |