# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
128453 | dragonslayerit | Coin Collecting (JOI19_ho_t4) | C++14 | 2 ms | 376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <algorithm>
#include <stdint.h>
struct Point{
int64_t x,y;
void read(){
scanf("%ld %ld",&x,&y);
}
bool operator<(Point p)const{
return x<p.x;
}
}ps[200005];
int main(){
int N;
scanf("%d",&N);
for(int i=0;i<N*2;i++){
ps[i].read();
}
std::sort(ps,ps+N*2);
int64_t cost=0;
for(int i=0;i<N*2;i++){
int64_t x=i/2+1;
cost+=std::abs(ps[i].x-x);
ps[i].x=x;
std::swap(ps[i].x,ps[i].y);
}
for(int i=0;i<N;i++){
std::sort(ps+i*2,ps+(i+1)*2);
cost+=std::abs(ps[i*2].x-1);
cost+=std::abs(ps[i*2+1].x-2);
}
printf("%ld\n",cost);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |