# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234850 | jhnah917 | 화살표 그리기 (KOI18_arrowH) | C++14 | 41 ms | 5624 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>
#define x first
#define y second
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
int n;
vector<int> v[101010];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n;
for(int i=0; i<n; i++){
int a, b; cin >> a >> b;
v[b].push_back(a);
}
ll ans = 0;
for(int i=0; i<101010; i++){
sort(all(v[i]));
if(v[i].size() <= 1) continue;
for(int j=0; j<v[i].size(); j++){
if(j == 0) ans += v[i][1] - v[i][j];
else if(j == v[i].size() - 1) ans += v[i][j] - v[i][j-1];
else ans += min(v[i][j] - v[i][j-1], v[i][j+1] - v[i][j]);
}
}
cout << 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... |