# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
121084 | 2019-06-26T05:19:30 Z | 임유진(#2971) | Coin Collecting (JOI19_ho_t4) | C++14 | 2 ms | 384 KB |
#include<stdio.h> #include<algorithm> using namespace std; #define MAXN 100005 typedef long long lint; typedef pair<lint, lint> pll; pll c[2*MAXN]; int main(){ int N; lint ans=0; scanf("%d", &N); for(int i=0; i<2*N; i++) scanf("%lld%lld", &c[i].first, &c[i].second); sort(c, c+2*N); for(int i=0; i<2*N; i++){ int k; for(k=0; i+k<2*N&&c[i].first==c[i+k].first; k++); k--; if(k%2==1) k--; //printf("(%d %d)", i, k); for(int j=0; j<=k/2; j++) swap(c[i+j], c[i+k-j]); i+=k; } //for(int i=0; i<2*N; i++) printf("[%d %d]\n", c[i].first, c[i].second); for(int i=0; i<N; i++) ans+=abs(c[i*2].first-i-1)+abs(min(c[i*2].second, c[i*2+1].second)-1)+abs(c[i*2+1].first-i-1)+abs(max(c[i*2].second, c[i*2+1].second)-2); printf("%lld", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Incorrect | 2 ms | 256 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Incorrect | 2 ms | 256 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Incorrect | 2 ms | 256 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |