답안 #85064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
85064 2018-11-18T11:20:41 Z tjdgus4384 화살표 그리기 (KOI18_arrowH) C++14
33 / 100
9 ms 3468 KB
#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

arrow.cpp: In function 'int main()':
arrow.cpp:21:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 1;j < v[i].size() - 1;j++)
                       ~~^~~~~~~~~~~~~~~~~
arrow.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
arrow.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &x, &c);
         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2720 KB Output is correct
4 Correct 4 ms 2728 KB Output is correct
5 Correct 4 ms 2824 KB Output is correct
6 Correct 4 ms 2828 KB Output is correct
7 Correct 4 ms 2876 KB Output is correct
8 Correct 4 ms 2880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2720 KB Output is correct
4 Correct 4 ms 2728 KB Output is correct
5 Correct 4 ms 2824 KB Output is correct
6 Correct 4 ms 2828 KB Output is correct
7 Correct 4 ms 2876 KB Output is correct
8 Correct 4 ms 2880 KB Output is correct
9 Correct 5 ms 2944 KB Output is correct
10 Correct 5 ms 2964 KB Output is correct
11 Correct 4 ms 2996 KB Output is correct
12 Correct 5 ms 3096 KB Output is correct
13 Correct 5 ms 3096 KB Output is correct
14 Correct 5 ms 3116 KB Output is correct
15 Correct 5 ms 3140 KB Output is correct
16 Correct 5 ms 3168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2720 KB Output is correct
4 Correct 4 ms 2728 KB Output is correct
5 Correct 4 ms 2824 KB Output is correct
6 Correct 4 ms 2828 KB Output is correct
7 Correct 4 ms 2876 KB Output is correct
8 Correct 4 ms 2880 KB Output is correct
9 Correct 5 ms 2944 KB Output is correct
10 Correct 5 ms 2964 KB Output is correct
11 Correct 4 ms 2996 KB Output is correct
12 Correct 5 ms 3096 KB Output is correct
13 Correct 5 ms 3096 KB Output is correct
14 Correct 5 ms 3116 KB Output is correct
15 Correct 5 ms 3140 KB Output is correct
16 Correct 5 ms 3168 KB Output is correct
17 Incorrect 9 ms 3468 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2720 KB Output is correct
4 Correct 4 ms 2728 KB Output is correct
5 Correct 4 ms 2824 KB Output is correct
6 Correct 4 ms 2828 KB Output is correct
7 Correct 4 ms 2876 KB Output is correct
8 Correct 4 ms 2880 KB Output is correct
9 Correct 5 ms 2944 KB Output is correct
10 Correct 5 ms 2964 KB Output is correct
11 Correct 4 ms 2996 KB Output is correct
12 Correct 5 ms 3096 KB Output is correct
13 Correct 5 ms 3096 KB Output is correct
14 Correct 5 ms 3116 KB Output is correct
15 Correct 5 ms 3140 KB Output is correct
16 Correct 5 ms 3168 KB Output is correct
17 Incorrect 9 ms 3468 KB Output isn't correct
18 Halted 0 ms 0 KB -