# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
269476 | sean9892 | 화살표 그리기 (KOI18_arrowH) | C++14 | 117 ms | 7612 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<int> v[100010];
set<int> s;
int main(void){
ios::sync_with_stdio(0);cin.tie(0);
int n;
cin>>n;
for(int i=0;i<n;i++){
int x,y;
cin>>x>>y;
v[y].push_back(x);
s.insert(y);
}
long long sum=0;
for(int c:s){
sort(v[c].begin(),v[c].end());
if(v[c].size()==1)continue;
auto& w=v[c];
sum+=1ll*w[1]-w[0]+w[w.size()-1]-w[w.size()-2];
for(int i=1;i<w.size()-1;i++){
sum+=min(w[i]-w[i-1],w[i+1]-w[i]);
}
}
cout<<sum;
}
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... |