Submission #63159

#TimeUsernameProblemLanguageResultExecution timeMemory
63159comfile화살표 그리기 (KOI18_arrowH)C++17
100 / 100
77 ms12812 KiB
#include <bits/stdc++.h> #define N 100010 #define pb push_back #define mp make_pair using namespace std; typedef long long ll; vector<int> v[N]; int n; pair<int,int> a[N]; int main(){ scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d%d",&a[i].first,&a[i].second); sort(a,a+n); for(int i=0;i<n;i++) v[a[i].second].pb(a[i].first); ll ans=0; for(int i=1;i<=n;i++){ for(int j=0;j<v[i].size();j++){ if(!j && v[i].size()>1) ans+=(ll)(v[i][1]-v[i][0]); if(j==(v[i].size()-1) && v[i].size()>1) ans+=(ll)(v[i][j]-v[i][j-1]); if(v[i].size()>2 && j>0 && j<v[i].size()-1) ans+=(ll)min(v[i][j+1]-v[i][j],v[i][j]-v[i][j-1]); } } printf("%lld\n",ans); return 0; }

Compilation message (stderr)

arrow.cpp: In function 'int main()':
arrow.cpp:17:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<v[i].size();j++){
                     ~^~~~~~~~~~~~
arrow.cpp:19:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(j==(v[i].size()-1) && v[i].size()>1) ans+=(ll)(v[i][j]-v[i][j-1]);
                ~^~~~~~~~~~~~~~~~~
arrow.cpp:20:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(v[i].size()>2 && j>0 && j<v[i].size()-1) ans+=(ll)min(v[i][j+1]-v[i][j],v[i][j]-v[i][j-1]);
                                        ~^~~~~~~~~~~~~~
arrow.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
arrow.cpp:12:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++) scanf("%d%d",&a[i].first,&a[i].second);
                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...