# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
85064 | tjdgus4384 | 화살표 그리기 (KOI18_arrowH) | C++14 | 9 ms | 3468 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<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> v[100001];
int main()
{
int x, n, c, ans = 0;
scanf("%d", &n);
for(int i = 0;i < n;i++)
{
scanf("%d %d", &x, &c);
v[c].push_back(x);
}
for(int i = 1;i <= n;i++)
{
if(v[i].size() <= 1) continue;
sort(v[i].begin(), v[i].end());
ans += v[i][1] - v[i][0];
for(int j = 1;j < v[i].size() - 1;j++)
{
ans += min(v[i][j] - v[i][j - 1], v[i][j + 1] - v[i][j]);
}
ans += v[i][v[i].size() - 1] - v[i][v[i].size() - 2];
}
printf("%d", ans);
return 0;
}
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... |