# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1111350 | 2024-11-12T07:23:20 Z | fyan | Coin Collecting (JOI19_ho_t4) | C++14 | 1 ms | 4432 KB |
#include "bits/stdc++.h" using namespace std; #define all(x) begin(x), end(x) #define sz(x) (int) (x).size() #define int long long const int mxn = 2e5+5; int N,X[mxn],Y[mxn]; int A[2][mxn]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N; int res = 0; for (int i=0; i<2*N; i++) { cin>>X[i]>>Y[i]; if (X[i] < 1) { res += 1-X[i]; X[i] = 1; } if (X[i] > N) { res += X[i]-N; X[i] = N; } if (Y[i] < 1) { res += 1-Y[i]; Y[i] = 1; } if (Y[i] > 2) { res += Y[i]-2; Y[i] = 2; } A[Y[i]][X[i]]++; } int t1=0, t2=0; for (int i=1; i<=N; i++) { t1 += A[1][i] - 1; t2 += A[2][i] - 1; if (t1 < 0 && t2 > 0) { int t = min(-t1,t2); res += t; t1 += t; t2 -= t; } if (t1 > 0 && t2 < 0) { int t = min(t1,-t2); res += t; t1 -= t; t2 += t; } res += abs(t1); res += abs(t2); } cout<<res; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4432 KB | Output is correct |
2 | Correct | 1 ms | 4432 KB | Output is correct |
3 | Correct | 1 ms | 4432 KB | Output is correct |
4 | Incorrect | 1 ms | 4432 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4432 KB | Output is correct |
2 | Correct | 1 ms | 4432 KB | Output is correct |
3 | Correct | 1 ms | 4432 KB | Output is correct |
4 | Incorrect | 1 ms | 4432 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4432 KB | Output is correct |
2 | Correct | 1 ms | 4432 KB | Output is correct |
3 | Correct | 1 ms | 4432 KB | Output is correct |
4 | Incorrect | 1 ms | 4432 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |