답안 #82613

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82613 2018-11-01T00:48:09 Z chunghan 화살표 그리기 (KOI18_arrowH) C++17
100 / 100
68 ms 16596 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long int lld;

vector<int> A[100005];

int x, y, N;
lld rst;

int main() {
    scanf("%d", &N);
    for(int i = 0; i < N; i++) {
        scanf("%d %d", &x, &y);
        A[y].push_back(x);
    }
    for(int i = 1; i <= N; i++) {
        sort(A[i].begin(), A[i].end());
        if(A[i].size() == 1) continue;
        for(int j = 0; j < A[i].size(); j++) {
            int tmp = 2e9;
            if(j != 0) tmp = min(tmp, A[i][j]-A[i][j-1]);
            if(j != A[i].size()-1) tmp = min(tmp, A[i][j+1]-A[i][j]);
            rst += tmp;
        }
    }
    printf("%lld\n", rst);
    return 0;
}

Compilation message

arrow.cpp: In function 'int main()':
arrow.cpp:21:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j < A[i].size(); j++) {
                        ~~^~~~~~~~~~~~~
arrow.cpp:24:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(j != A[i].size()-1) tmp = min(tmp, A[i][j+1]-A[i][j]);
                ~~^~~~~~~~~~~~~~~~
arrow.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
arrow.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2744 KB Output is correct
3 Correct 4 ms 2788 KB Output is correct
4 Correct 4 ms 2788 KB Output is correct
5 Correct 4 ms 2856 KB Output is correct
6 Correct 4 ms 2856 KB Output is correct
7 Correct 4 ms 2856 KB Output is correct
8 Correct 4 ms 2856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2744 KB Output is correct
3 Correct 4 ms 2788 KB Output is correct
4 Correct 4 ms 2788 KB Output is correct
5 Correct 4 ms 2856 KB Output is correct
6 Correct 4 ms 2856 KB Output is correct
7 Correct 4 ms 2856 KB Output is correct
8 Correct 4 ms 2856 KB Output is correct
9 Correct 4 ms 2856 KB Output is correct
10 Correct 4 ms 2856 KB Output is correct
11 Correct 4 ms 2992 KB Output is correct
12 Correct 5 ms 3116 KB Output is correct
13 Correct 5 ms 3160 KB Output is correct
14 Correct 4 ms 3160 KB Output is correct
15 Correct 4 ms 3160 KB Output is correct
16 Correct 5 ms 3160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2744 KB Output is correct
3 Correct 4 ms 2788 KB Output is correct
4 Correct 4 ms 2788 KB Output is correct
5 Correct 4 ms 2856 KB Output is correct
6 Correct 4 ms 2856 KB Output is correct
7 Correct 4 ms 2856 KB Output is correct
8 Correct 4 ms 2856 KB Output is correct
9 Correct 4 ms 2856 KB Output is correct
10 Correct 4 ms 2856 KB Output is correct
11 Correct 4 ms 2992 KB Output is correct
12 Correct 5 ms 3116 KB Output is correct
13 Correct 5 ms 3160 KB Output is correct
14 Correct 4 ms 3160 KB Output is correct
15 Correct 4 ms 3160 KB Output is correct
16 Correct 5 ms 3160 KB Output is correct
17 Correct 7 ms 3300 KB Output is correct
18 Correct 7 ms 3424 KB Output is correct
19 Correct 7 ms 3544 KB Output is correct
20 Correct 8 ms 3688 KB Output is correct
21 Correct 7 ms 3800 KB Output is correct
22 Correct 6 ms 3904 KB Output is correct
23 Correct 7 ms 4068 KB Output is correct
24 Correct 8 ms 4268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2744 KB Output is correct
3 Correct 4 ms 2788 KB Output is correct
4 Correct 4 ms 2788 KB Output is correct
5 Correct 4 ms 2856 KB Output is correct
6 Correct 4 ms 2856 KB Output is correct
7 Correct 4 ms 2856 KB Output is correct
8 Correct 4 ms 2856 KB Output is correct
9 Correct 4 ms 2856 KB Output is correct
10 Correct 4 ms 2856 KB Output is correct
11 Correct 4 ms 2992 KB Output is correct
12 Correct 5 ms 3116 KB Output is correct
13 Correct 5 ms 3160 KB Output is correct
14 Correct 4 ms 3160 KB Output is correct
15 Correct 4 ms 3160 KB Output is correct
16 Correct 5 ms 3160 KB Output is correct
17 Correct 7 ms 3300 KB Output is correct
18 Correct 7 ms 3424 KB Output is correct
19 Correct 7 ms 3544 KB Output is correct
20 Correct 8 ms 3688 KB Output is correct
21 Correct 7 ms 3800 KB Output is correct
22 Correct 6 ms 3904 KB Output is correct
23 Correct 7 ms 4068 KB Output is correct
24 Correct 8 ms 4268 KB Output is correct
25 Correct 50 ms 7008 KB Output is correct
26 Correct 39 ms 7636 KB Output is correct
27 Correct 46 ms 9496 KB Output is correct
28 Correct 38 ms 10476 KB Output is correct
29 Correct 68 ms 12256 KB Output is correct
30 Correct 39 ms 13304 KB Output is correct
31 Correct 39 ms 14556 KB Output is correct
32 Correct 67 ms 16596 KB Output is correct