# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65657 | sebinkim | 화살표 그리기 (KOI18_arrowH) | C++14 | 71 ms | 17180 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;
vector <ll> V[101010];
ll n, ans;
int main()
{
ll i, j, a, b;
scanf("%lld", &n);
for(i=0; i<n; i++){
scanf("%lld%lld", &a, &b);
V[b].push_back(a);
}
for(i=1; i<=n; i++){
if(V[i].size() < 2) continue;
sort(V[i].begin(), V[i].end());
for(j=0; j<V[i].size(); j++){
if(j == 0) ans += V[i][j+1] - V[i][j];
else if(j + 1 == V[i].size()) ans += V[i][j] - V[i][j-1];
else ans += min(V[i][j+1] - V[i][j], V[i][j] - V[i][j-1]);
}
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... |