Submission #126798

#TimeUsernameProblemLanguageResultExecution timeMemory
126798arnold518화살표 그리기 (KOI18_arrowH)C++14
100 / 100
51 ms5496 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int N; vector<int> V[MAXN+10]; ll ans; int main() { int i, j; scanf("%d", &N); for(i=1; i<=N; i++) { int x, y; scanf("%d%d", &x, &y); V[y].push_back(x); } for(i=1; i<=N; i++) sort(V[i].begin(), V[i].end()); for(i=1; i<=N; i++) { if(V[i].size()<=1) continue; ans+=V[i][1]-V[i][0]; ans+=V[i][V[i].size()-1]-V[i][V[i].size()-2]; for(j=1; j+1<V[i].size(); j++) ans+=min(V[i][j+1]-V[i][j], V[i][j]-V[i][j-1]); } printf("%lld", ans); }

Compilation message (stderr)

arrow.cpp: In function 'int main()':
arrow.cpp:32:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(j=1; j+1<V[i].size(); j++) ans+=min(V[i][j+1]-V[i][j], V[i][j]-V[i][j-1]);
                  ~~~^~~~~~~~~~~~
arrow.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
arrow.cpp:22: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...