제출 #82613

#제출 시각아이디문제언어결과실행 시간메모리
82613chunghan화살표 그리기 (KOI18_arrowH)C++17
100 / 100
68 ms16596 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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);
         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...