# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
727109 | 2023-04-20T04:10:23 Z | iskhakkutbilim | Road Closures (APIO21_roads) | C++14 | 52 ms | 5028 KB |
#include "roads.h" #include <bits/stdc++.h> using namespace std; #define ff first #define ss second vector<long long> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) { vector<long long> ans; int sub1 = 1, sub2 = 1; for(int i = 0;i < N-1; i++){ if(U[i] != 0) sub1 = 0; if(U[i] != i or V[i] != i+1) sub2 = 0; } long long sum = 0LL; for(int i = 0;i < N-1; i++) sum+= W[i]; ans.push_back(sum); if(sub1){ sort(W.begin(), W.end()); for(int i = N - 2;i >= 0; i--){ sum -= W[i] * 1LL; ans.push_back(sum); } }else if(sub2){ ans.push_back(sum); sum = 0; for(int i = 0;i < N-1; i++){ if(i%2==0) sum+= W[i]; } ans.push_back(sum); sum = 0; for(int i = 0;i < N-1; i++){ if(i%2==1) sum+= W[i]; } if(ans.back()>sum){ ans.pop_back(); ans.push_back(sum); } while(ans.size() < N) ans.push_back(0LL); }else{ assert(false); } if(ans.size() != N) assert(false); return ans; } //main(){ // int N; cin >> N; // vector<int> U(N), V(N), W(N); // for(int i = 0;i < N-1; i++){ // cin >> U[i] >> V[i]; // } // for(int i = 0;i < N-1; i++) cin >> W[i]; // // vector<long long> ans = minimum_closure_costs(N, U, V, W); // //}
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 2 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 25 ms | 2300 KB | Output is correct |
13 | Correct | 36 ms | 3780 KB | Output is correct |
14 | Correct | 42 ms | 3532 KB | Output is correct |
15 | Correct | 45 ms | 3776 KB | Output is correct |
16 | Correct | 46 ms | 3800 KB | Output is correct |
17 | Correct | 52 ms | 3864 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 31 ms | 3532 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 43 ms | 3336 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Runtime error | 1 ms | 340 KB | Execution killed with signal 6 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Runtime error | 1 ms | 340 KB | Execution killed with signal 6 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 28 ms | 5028 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 28 ms | 5028 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 2 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 25 ms | 2300 KB | Output is correct |
13 | Correct | 36 ms | 3780 KB | Output is correct |
14 | Correct | 42 ms | 3532 KB | Output is correct |
15 | Correct | 45 ms | 3776 KB | Output is correct |
16 | Correct | 46 ms | 3800 KB | Output is correct |
17 | Correct | 52 ms | 3864 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 31 ms | 3532 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Incorrect | 43 ms | 3336 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |