제출 #771834

#제출 시각아이디문제언어결과실행 시간메모리
7718341binExamination (JOI19_examination)C++14
0 / 100
24 ms4040 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() typedef long long ll; const int NMAX = 1e5 + 5; ll n, x, y, ans, cnt[NMAX][2], a, b; int main(void){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 0; i < 2 * n; i++){ cin >> x >> y; if(x < 1) ans += 1 - x, x = 1; else if(x > n) ans += x - n, x = n; if(y >= 2) ans += y - 2, y = 1; else ans += 1 - y, y = 0; cnt[x][y]++; } for(int i = 1; i <= n; i++){ a += cnt[i][0] - 1; b += cnt[i][1] - 1; ans += abs(a + b); } ans += abs(a); cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...