Submission #63151

#TimeUsernameProblemLanguageResultExecution timeMemory
63151khsoo01화살표 그리기 (KOI18_arrowH)C++11
100 / 100
72 ms16632 KiB
#include<bits/stdc++.h> using namespace std; const int N = 100005, inf = 2e9; int n; long long ans; vector<int> v[N]; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { int A, B; scanf("%d%d",&A,&B); v[B].push_back(A); } for(int i=1;i<=n;i++) { sort(v[i].begin(), v[i].end()); if(v[i].size() == 1) continue; for(int j=0;j<(int)v[i].size();j++) { int T = inf; if(j != 0) T = min(T, v[i][j] - v[i][j-1]); if(j != (int)v[i].size() - 1) T = min(T, v[i][j+1] - v[i][j]); ans += T; } } printf("%lld\n",ans); }

Compilation message (stderr)

arrow.cpp: In function 'int main()':
arrow.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
arrow.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&A,&B);
   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...