# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145544 | surface03 | 화살표 그리기 (KOI18_arrowH) | C++14 | 52 ms | 5976 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
vector<long long>v[100010];
int main(){
int n,i,j,x,y,len;
long long ans=0;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d%d",&x,&y);
v[y].push_back(x);
}
for(i=1;i<=n;i++){
sort(v[i].begin(),v[i].end());
}
for(i=1;i<=n;i++){
if(v[i].size()<=1)continue;
len=v[i].size();
for(j=1;j<len-1;j++){
ans+=min(v[i][j]-v[i][j-1],v[i][j+1]-v[i][j]);
}
ans+=v[i][1]-v[i][0];
ans+=v[i][len-1]-v[i][len-2];
}
printf("%lld",ans);
}
Compilation message (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |