# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63151 | khsoo01 | 화살표 그리기 (KOI18_arrowH) | C++11 | 72 ms | 16632 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;
const int N = 100005, inf = 2e9;
int n;
long long ans;
vector<int> v[N];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++) {
int A, B;
scanf("%d%d",&A,&B);
v[B].push_back(A);
}
for(int i=1;i<=n;i++) {
sort(v[i].begin(), v[i].end());
if(v[i].size() == 1) continue;
for(int j=0;j<(int)v[i].size();j++) {
int T = inf;
if(j != 0) T = min(T, v[i][j] - v[i][j-1]);
if(j != (int)v[i].size() - 1) T = min(T, v[i][j+1] - v[i][j]);
ans += T;
}
}
printf("%lld\n",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... |