Submission #110902

#TimeUsernameProblemLanguageResultExecution timeMemory
110902oolimryCoin Collecting (JOI19_ho_t4)C++14
0 / 100
2 ms384 KiB
#include <bits/stdc++.h> using namespace std; int main() { //freopen("i.txt","r",stdin); ios_base::sync_with_stdio(false); cin.tie(0); long long ans = 0ll; int n; cin >> n; int arr[n][2]; for(int i = 0;i < n;i++){ arr[i][0] = 0; arr[i][1] = 0; } for(int i = 0;i < 2 * n;i++){ long long x, y; cin >> x >> y; if(x <= 1){ if(y <= 1){ arr[0][0]++; ans += abs(y-1) + abs(x-1); } else{ arr[0][1]++; ans += abs(y-2) + abs(x-1); } } else if(x >= n){ if(y <= 1){ arr[n-1][0]++; ans += abs(y-1) + abs(x-n); } else{ arr[n-1][1]++; ans += abs(y-2) + abs(x-n); } } else{ if(y <= 1){ arr[x-1][0]++; ans += abs(y-1); } else{ arr[x-1][1]++; ans += abs(y-2); } } } int comb[n]; int col = 0; for(int i = 0;i < n;i++){ comb[i] = arr[i][0] + arr[i][1]; col += arr[i][0]; col -= arr[i][1]; } for(int i = 0;i < n;i++){ int x = comb[i] - 2; ans += abs(x); comb[i] = 2; if(i != n-1) comb[i+1] += x; } col /= 2; ans += abs(col); cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...