Submission #145544

#TimeUsernameProblemLanguageResultExecution timeMemory
145544surface03화살표 그리기 (KOI18_arrowH)C++14
100 / 100
52 ms5976 KiB
#include<bits/stdc++.h> using namespace std; vector<long long>v[100010]; int main(){ int n,i,j,x,y,len; long long ans=0; scanf("%d",&n); for(i=1;i<=n;i++){ 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; len=v[i].size(); for(j=1;j<len-1;j++){ ans+=min(v[i][j]-v[i][j-1],v[i][j+1]-v[i][j]); } ans+=v[i][1]-v[i][0]; ans+=v[i][len-1]-v[i][len-2]; } printf("%lld",ans); }

Compilation message (stderr)

arrow.cpp: In function 'int main()':
arrow.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
arrow.cpp:9: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...