# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
121289 | 2019-06-26T09:44:43 Z | imyujin | Unique Cities (JOI19_ho_t5) | C++14 | 68 ms | 8696 KB |
#include<stdio.h> #include<algorithm> using namespace std; #define MAXN 100005 using namespace std; typedef long long lint; lint X[2*MAXN], Y[2*MAXN]; int S[2*MAXN][3]; int main(){ int N; lint ans=0; scanf("%d", &N); for(int i=0; i<2*N; i++) scanf("%lld%lld", X+i, Y+i); for(int i=0; i<2*N; i++){ int x, y; if(X[i]<=0) x=1; else if(X[i]>N) x=N; else x=X[i]; y=Y[i]>=2?2:1; ans+=abs(X[i]-x)+abs(Y[i]-y); S[x][y]++; //printf("(%d, %d)\n", x, y); } for(int i=1; i<=N; i++){ S[i][1]--; S[i][2]--; //printf("[%d %d]\n", S[i][1], S[i][2]); } for(int i=1; i<=N; i++){ if((long long)S[i][1]*S[i][2]<0){ if(abs(S[i][1])>abs(S[i][2])){ ans+=abs(S[i][2]); S[i][1]+=S[i][2]; S[i][2]=0; } else{ ans+=abs(S[i][1]); S[i][2]+=S[i][1]; S[i][1]=0; } } ans+=abs(S[i][1]); ans+=abs(S[i][2]); S[i+1][1]+=S[i][1]; S[i+1][2]+=S[i][2]; } printf("%lld", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 68 ms | 8696 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 43 ms | 3832 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |