Submission #82610

#TimeUsernameProblemLanguageResultExecution timeMemory
82610chunghan화살표 그리기 (KOI18_arrowH)C++17
0 / 100
5 ms3008 KiB
#include<bits/stdc++.h>

using namespace std;

typedef long long int lld;
typedef pair<lld, lld> pll;

vector<lld> A[100001];

lld x, y, N;
lld rst;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> 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++) {
            lld 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;
        }
    }
    cout << rst;
    return 0;
}

Compilation message (stderr)

arrow.cpp: In function 'int main()':
arrow.cpp:24:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j < A[i].size(); j++) {
                        ~~^~~~~~~~~~~~~
arrow.cpp:27: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]);
                ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...