Submission #1079425

#TimeUsernameProblemLanguageResultExecution timeMemory
1079425JooDdaeCoin Collecting (JOI19_ho_t4)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, x[200200], y[200200], c[100100][2]; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n; for(int i=1;i<=n+n;i++) cin >> x[i] >> y[i]; ll ans = 0, c1 = 0; for(int i=1;i<=n+n;i++) { int D = min(max(x[i], 1), n); ans += abs(D-x[i]); if(y[i] >= 2) { c[D][0]++, c1++; ans += y[i]-2; } else { c[D][1]++; ans += 1-y[i]; } } ll S = 0; for(int i=1;i<=n;i++) { S += c[i][0]+c[i][1]-2; ans += abs(S); } cout << ans + abs(c1-n); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...