Submission #62756

#TimeUsernameProblemLanguageResultExecution timeMemory
62756jjwdi0화살표 그리기 (KOI18_arrowH)C++11
100 / 100
86 ms16688 KiB
#include <bits/stdc++.h> using namespace std; int N; vector<int> v[100005]; long long ans; int main() { scanf("%d", &N); for(int i=1, x, y; i<=N; i++) scanf("%d %d", &x, &y), v[y].push_back(x); for(int i=1; i<=N; i++) sort(v[i].begin(), v[i].end()); for(int i=1; i<=N; i++) { if(v[i].size() == 1) continue; for(int j=0; j<v[i].size(); j++) { if(j == 0) ans += 1LL * (v[i][j+1] - v[i][j]); else if(j == v[i].size() - 1) ans += 1LL * (v[i][j] - v[i][j-1]); else ans += min(v[i][j+1] - v[i][j], v[i][j] - v[i][j-1]); } } printf("%lld\n", ans); }

Compilation message (stderr)

arrow.cpp: In function 'int main()':
arrow.cpp:14:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0; j<v[i].size(); j++) {
                      ~^~~~~~~~~~~~
arrow.cpp:16:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             else if(j == v[i].size() - 1) ans += 1LL * (v[i][j] - v[i][j-1]);
                     ~~^~~~~~~~~~~~~~~~~~
arrow.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
arrow.cpp:10:57: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1, x, y; i<=N; i++) scanf("%d %d", &x, &y), v[y].push_back(x);
                                   ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...