| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1302733 | ducdev | 화살표 그리기 (KOI18_arrowH) | C++17 | 33 ms | 25224 KiB |
// Author: 4uckd3v - Nguyen Cao Duc
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1e6;
const int MOD = 1e9 + 7;
vector<int> pos[MAX_N + 5];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
if (fopen("ARROW.INP", "r")) {
freopen("ARROW.INP", "r", stdin);
freopen("ARROW.OUT", "w", stdout);
};
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
int x, color;
cin >> x >> color;
pos[color].push_back(x);
};
ll res = 0;
for (int i = 1; i <= MAX_N; i++) {
sort(pos[i].begin(), pos[i].end());
for (int j = 0; j < pos[i].size(); j++) {
int minDist = 2e9;
if (j > 0) minDist = min(minDist, pos[i][j] - pos[i][j - 1]);
if (j + 1 < pos[i].size()) minDist = min(minDist, pos[i][j + 1] - pos[i][j]);
if (minDist < 2e9)
res += minDist;
};
};
cout << res;
};
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... | ||||
