Task: | Going Dutch |
Sender: | Antti Röyskö |
Submission time: | 2017-10-24 18:56:53 +0300 |
Language: | C++ |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.08 s | details |
#2 | WRONG ANSWER | 0.05 s | details |
#3 | WRONG ANSWER | 0.39 s | details |
#4 | WRONG ANSWER | 0.05 s | details |
#5 | WRONG ANSWER | 0.09 s | details |
#6 | WRONG ANSWER | 0.03 s | details |
#7 | WRONG ANSWER | 0.36 s | details |
#8 | WRONG ANSWER | 0.10 s | details |
#9 | WRONG ANSWER | 0.05 s | details |
#10 | WRONG ANSWER | 0.06 s | details |
#11 | WRONG ANSWER | 0.04 s | details |
#12 | WRONG ANSWER | 0.43 s | details |
#13 | WRONG ANSWER | 0.07 s | details |
#14 | WRONG ANSWER | 0.09 s | details |
#15 | WRONG ANSWER | 0.49 s | details |
#16 | ACCEPTED | 0.05 s | details |
#17 | ACCEPTED | 0.04 s | details |
#18 | ACCEPTED | 0.03 s | details |
#19 | WRONG ANSWER | 0.07 s | details |
#20 | ACCEPTED | 0.04 s | details |
#21 | ACCEPTED | 0.06 s | details |
#22 | ACCEPTED | 0.05 s | details |
#23 | WRONG ANSWER | 0.04 s | details |
#24 | WRONG ANSWER | 0.05 s | details |
#25 | WRONG ANSWER | 0.04 s | details |
#26 | ACCEPTED | 0.04 s | details |
#27 | ACCEPTED | 0.04 s | details |
#28 | ACCEPTED | 0.06 s | details |
#29 | ACCEPTED | 0.03 s | details |
#30 | WRONG ANSWER | 0.03 s | details |
#31 | WRONG ANSWER | 0.03 s | details |
#32 | ACCEPTED | 0.03 s | details |
#33 | ACCEPTED | 0.03 s | details |
#34 | WRONG ANSWER | 0.03 s | details |
#35 | ACCEPTED | 0.05 s | details |
#36 | WRONG ANSWER | 0.04 s | details |
#37 | ACCEPTED | 0.05 s | details |
#38 | WRONG ANSWER | 0.04 s | details |
#39 | WRONG ANSWER | 0.04 s | details |
#40 | WRONG ANSWER | 0.04 s | details |
#41 | ACCEPTED | 0.05 s | details |
#42 | WRONG ANSWER | 0.04 s | details |
#43 | ACCEPTED | 0.07 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:27:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < v1.size(); ++i) { ^ input/code.cpp:30:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < v2.size(); ++i) { ^ input/code.cpp:40:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < v1.size(); ++i) { ^
Code
#include <bits/stdc++.h> using namespace std; int t[22]; int main() { int m,n; cin>>m>>n; for(int i = 0; i < n; ++i) { int a,b,p; cin>>a>>b>>p; t[b] += p; t[a] -= p; } vector<int> v1; vector<int> v2; for(int i = 0; i < m; ++i) { if(t[i] < 0) v1.push_back(t[i]); if(t[i] > 0) v2.push_back(t[i]); } if(v1.size() == 0) { cout<<0<<endl; return 0; } if(v1.size() > v2.size()) { swap(v1, v2); } if(v1[0] > 0) { for(int i = 0; i < v1.size(); ++i) { v1[i] = -v1[i]; } for(int i = 0; i < v2.size(); ++i) { v2[i] = -v2[i]; } } sort(v1.begin(), v1.end()); int ans = 1e9; do { int res = 0; int p2 = 0; auto v3 = v2; for(int i = 0; i < v1.size(); ++i) { int val = v1[i]; while(val < 0) { int q = min(-val, v3[p2]); v3[p2] -= q; val += q; res++; if(v3[p2] == 0) ++p2; } } ans = min(ans, res); } while(next_permutation(v1.begin(), v1.end())); cout<<ans<<'\n'; }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
20 144 0 1 1000 0 1 1000 0 1 1000 0 1 1000 ... |
correct output |
---|
16 |
user output |
---|
18 |
Test 2
Verdict: WRONG ANSWER
input |
---|
20 121 1 0 578 0 2 1000 0 2 1000 0 2 1000 ... |
correct output |
---|
17 |
user output |
---|
19 |
Test 3
Verdict: WRONG ANSWER
input |
---|
20 144 0 1 1000 0 1 1000 0 1 883 0 2 1000 ... |
correct output |
---|
17 |
user output |
---|
19 |
Test 4
Verdict: WRONG ANSWER
input |
---|
20 119 1 0 1000 1 0 1000 1 0 1000 1 0 1000 ... |
correct output |
---|
16 |
user output |
---|
19 |
Test 5
Verdict: WRONG ANSWER
input |
---|
20 167 0 1 1000 0 1 219 0 2 1000 0 2 1000 ... |
correct output |
---|
16 |
user output |
---|
18 |
Test 6
Verdict: WRONG ANSWER
input |
---|
20 116 1 0 1000 1 0 1000 1 0 1000 1 0 1000 ... |
correct output |
---|
16 |
user output |
---|
19 |
Test 7
Verdict: WRONG ANSWER
input |
---|
20 160 1 0 1000 1 0 1000 1 0 1000 1 0 1000 ... |
correct output |
---|
16 |
user output |
---|
19 |
Test 8
Verdict: WRONG ANSWER
input |
---|
20 123 0 1 1000 0 1 1000 0 1 1000 0 1 1000 ... |
correct output |
---|
16 |
user output |
---|
19 |
Test 9
Verdict: WRONG ANSWER
input |
---|
20 170 0 1 1000 0 1 1000 0 1 1000 0 1 1000 ... |
correct output |
---|
16 |
user output |
---|
19 |
Test 10
Verdict: WRONG ANSWER
input |
---|
20 210 1 0 1000 1 0 1000 1 0 1000 1 0 1000 ... |
correct output |
---|
15 |
user output |
---|
19 |
Test 11
Verdict: WRONG ANSWER
input |
---|
20 100 1 0 1000 1 0 1000 1 0 420 0 2 1000 ... |
correct output |
---|
15 |
user output |
---|
18 |
Test 12
Verdict: WRONG ANSWER
input |
---|
20 123 1 0 1000 1 0 1000 1 0 1000 1 0 1000 ... |
correct output |
---|
15 |
user output |
---|
19 |
Test 13
Verdict: WRONG ANSWER
input |
---|
20 138 1 0 1000 1 0 1000 1 0 1000 1 0 1000 ... |
correct output |
---|
14 |
user output |
---|
19 |
Test 14
Verdict: WRONG ANSWER
input |
---|
20 132 1 0 1000 1 0 1000 1 0 1000 1 0 1000 ... |
correct output |
---|
15 |
user output |
---|
18 |
Test 15
Verdict: WRONG ANSWER
input |
---|
20 141 0 1 1000 0 1 1000 0 1 1000 0 1 1000 ... |
correct output |
---|
15 |
user output |
---|
18 |
Test 16
Verdict: ACCEPTED
input |
---|
20 380 0 1 20 0 2 20 0 3 20 0 4 20 ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 17
Verdict: ACCEPTED
input |
---|
20 0 |
correct output |
---|
0 |
user output |
---|
0 |
Test 18
Verdict: ACCEPTED
input |
---|
3 1000 0 1 1000 0 1 1000 0 1 1000 0 1 1000 ... |
correct output |
---|
1 |
user output |
---|
1 |
Test 19
Verdict: WRONG ANSWER
input |
---|
13 12 1 0 1 2 0 1 3 0 10 4 0 10 ... |
correct output |
---|
9 |
user output |
---|
10 |
Test 20
Verdict: ACCEPTED
input |
---|
20 1 0 1 1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 21
Verdict: ACCEPTED
input |
---|
20 10 0 1 1 2 3 1 4 5 1 6 7 1 ... |
correct output |
---|
10 |
user output |
---|
10 |
Test 22
Verdict: ACCEPTED
input |
---|
6 49 0 4 3 3 0 1 5 0 10 1 0 1 ... |
correct output |
---|
5 |
user output |
---|
5 |
Test 23
Verdict: WRONG ANSWER
input |
---|
9 50 8 7 4 8 2 7 0 4 2 4 5 1 ... |
correct output |
---|
5 |
user output |
---|
6 |
Test 24
Verdict: WRONG ANSWER
input |
---|
20 296 6 11 22 15 11 1 9 4 1 8 6 4 ... |
correct output |
---|
16 |
user output |
---|
18 |
Test 25
Verdict: WRONG ANSWER
input |
---|
20 999 18 17 1 8 15 1 15 6 3 1 19 5 ... |
correct output |
---|
12 |
user output |
---|
15 |
Test 26
Verdict: ACCEPTED
input |
---|
20 997 1 0 1 0 19 14 13 3 8 6 13 8 ... |
correct output |
---|
10 |
user output |
---|
10 |
Test 27
Verdict: ACCEPTED
input |
---|
5 10 4 3 2 0 1 4 3 4 7 3 0 1 ... |
correct output |
---|
3 |
user output |
---|
3 |
Test 28
Verdict: ACCEPTED
input |
---|
20 26 12 13 7 19 16 2 15 14 2 4 3 1 ... |
correct output |
---|
8 |
user output |
---|
8 |
Test 29
Verdict: ACCEPTED
input |
---|
9 6 0 1 2 0 2 1 3 4 2 3 5 1 ... |
correct output |
---|
6 |
user output |
---|
6 |
Test 30
Verdict: WRONG ANSWER
input |
---|
18 16 0 1 1 0 2 1 3 4 1 3 5 1 ... |
correct output |
---|
12 |
user output |
---|
14 |
Test 31
Verdict: WRONG ANSWER
input |
---|
20 14 0 1 1 0 2 1 3 4 1 3 5 1 ... |
correct output |
---|
11 |
user output |
---|
12 |
Test 32
Verdict: ACCEPTED
input |
---|
20 11 0 1 2 3 2 1 5 4 1 6 8 2 ... |
correct output |
---|
11 |
user output |
---|
11 |
Test 33
Verdict: ACCEPTED
input |
---|
20 11 0 1 2 3 2 1 5 4 1 6 8 4 ... |
correct output |
---|
11 |
user output |
---|
11 |
Test 34
Verdict: WRONG ANSWER
input |
---|
9 6 4 8 6 4 5 2 2 6 5 3 7 5 ... |
correct output |
---|
6 |
user output |
---|
7 |
Test 35
Verdict: ACCEPTED
input |
---|
9 8 0 1 23 0 2 20 3 4 4 5 2 2 ... |
correct output |
---|
7 |
user output |
---|
7 |
Test 36
Verdict: WRONG ANSWER
input |
---|
15 13 1 0 1 2 0 1 3 5 5 4 5 5 ... |
correct output |
---|
12 |
user output |
---|
13 |
Test 37
Verdict: ACCEPTED
input |
---|
15 13 0 2 1000 1 2 1000 3 4 800 3 5 400 ... |
correct output |
---|
12 |
user output |
---|
12 |
Test 38
Verdict: WRONG ANSWER
input |
---|
18 16 0 2 1 1 2 1 3 7 10 4 7 10 ... |
correct output |
---|
15 |
user output |
---|
16 |
Test 39
Verdict: WRONG ANSWER
input |
---|
20 18 0 1 1 0 2 1 0 3 1 4 5 5 ... |
correct output |
---|
16 |
user output |
---|
18 |
Test 40
Verdict: WRONG ANSWER
input |
---|
20 42 0 1 1000 0 1 1000 0 1 1000 0 1 1000 ... |
correct output |
---|
16 |
user output |
---|
18 |
Test 41
Verdict: ACCEPTED
input |
---|
20 18 0 1 1000 0 1 1000 0 1 1000 0 1 1000 ... |
correct output |
---|
6 |
user output |
---|
6 |
Test 42
Verdict: WRONG ANSWER
input |
---|
20 15 1 0 1 3 0 1 5 2 1 6 2 1 ... |
correct output |
---|
13 |
user output |
---|
14 |
Test 43
Verdict: ACCEPTED
input |
---|
20 2 3 8 1 15 7 1 |
correct output |
---|
2 |
user output |
---|
2 |