답안 #82612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82612 2018-11-01T00:45:57 Z chunghan 화살표 그리기 (KOI18_arrowH) C++17
0 / 100
4 ms 2960 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", 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 2744 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 4 ms 2924 KB Output is correct
6 Correct 4 ms 2960 KB Output is correct
7 Incorrect 4 ms 2960 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2744 KB Output is correct
3 Correct 4 ms 2744 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 4 ms 2924 KB Output is correct
6 Correct 4 ms 2960 KB Output is correct
7 Incorrect 4 ms 2960 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2744 KB Output is correct
3 Correct 4 ms 2744 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 4 ms 2924 KB Output is correct
6 Correct 4 ms 2960 KB Output is correct
7 Incorrect 4 ms 2960 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2744 KB Output is correct
3 Correct 4 ms 2744 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 4 ms 2924 KB Output is correct
6 Correct 4 ms 2960 KB Output is correct
7 Incorrect 4 ms 2960 KB Output isn't correct
8 Halted 0 ms 0 KB -