# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
126798 | arnold518 | 화살표 그리기 (KOI18_arrowH) | C++14 | 51 ms | 5496 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5;
int N;
vector<int> V[MAXN+10];
ll ans;
int main()
{
int i, j;
scanf("%d", &N);
for(i=1; i<=N; i++)
{
int x, y;
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;
ans+=V[i][1]-V[i][0];
ans+=V[i][V[i].size()-1]-V[i][V[i].size()-2];
for(j=1; j+1<V[i].size(); j++) ans+=min(V[i][j+1]-V[i][j], V[i][j]-V[i][j-1]);
}
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... |