# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
140584 | khrbuddy03 | 화살표 그리기 (KOI18_arrowH) | C++14 | 48 ms | 6008 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;
const int inf = 1e5 + 9;
vector<ll> arr[inf];
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n; cin >> n;
for (int i = 0; i < n; i++) {
int x, y; cin >> x >> y;
arr[y].push_back(x);
}
ll ans = 0;
for (int i = 1; i <= n; i++) {
sort(arr[i].begin(), arr[i].end());
if (arr[i].size() == 1 || arr[i].size() == 0) continue;
else {
for (int j = 1; j < arr[i].size() - 1; j++) {
ans += min(arr[i][j] - arr[i][j - 1], arr[i][j + 1] - arr[i][j]);
}
ans += (arr[i][arr[i].size() - 1] - arr[i][arr[i].size() - 2]) + (arr[i][1] - arr[i][0]);
}
}
cout << ans << '\n';
}
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... |