# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
704102 | 1075508020060209tc | Coin Collecting (JOI19_ho_t4) | C++14 | 1 ms | 308 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
int n;
pair<int,int>ar[500005];
int vsa[500005];
int vsb[500005];
signed main(){
cin>>n;
for(int i=1;i<=n+n;i++){
cin>>ar[i].X>>ar[i].Y;
}
vector<pair<int,pair<int,int>>>seq;
for(int j=1;j<=n;j++){
for(int i=1;i<=n+n;i++){
int cst=abs(ar[i].X-j)+abs(ar[i].Y-1);
seq.push_back({cst,{i,j}});
}
}
for(int j=1;j<=n;j++){
for(int i=1;i<=n+n;i++){
int cst=abs(ar[i].X-j)+abs(ar[i].Y-2);
seq.push_back({cst,{i,j+n}});
}
}
sort(seq.begin(),seq.end());
int ans=0;
for(int i=0;i<seq.size();i++){
if(vsa[seq[i].second.first]==0&&vsb[seq[i].second.second]==0){
ans+=seq[i].first;
}
}
cout<<ans<<endl;
}
컴파일 시 표준 에러 (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... |