Submission #511032

#TimeUsernameProblemLanguageResultExecution timeMemory
511032blueCoin Collecting (JOI19_ho_t4)C++17
0 / 100
0 ms204 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; vvi A(1+2, vi(1+N, 0)); ll ans = 0; for(int i = 1; i <= 2*N; i++) { int X, Y; cin >> X >> Y; if(Y <= 1) { ans += 1-Y; Y = 1; } else { ans += Y-2; Y = 2; } if(X < 1) { ans += 1-X; X = 1; } else if(X > N) { ans += X-N; X = N; } A[Y][X]++; } for(int i = 1; i <= N; i++) { A[1][i]--; A[2][i]--; ll mov = 0; if(A[1][i] >= 0 && A[2][i] < 0) { mov = min(A[1][i], -A[2][i]); } else if(A[1][i] < 0 && A[2][i] >= 0) { mov = max(A[1][i], -A[2][i]); } // A[1][i] -= mov; // A[2][i] += mov; // ans += abs(mov); if(i < N) { A[1][i+1] += A[1][i]; A[2][i+1] += A[2][i]; ans += abs(A[1][i]); ans += abs(A[2][i]); } } cout << ans << '\n'; }

Compilation message (stderr)

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:57:12: warning: variable 'mov' set but not used [-Wunused-but-set-variable]
   57 |         ll mov = 0;
      |            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...