Submission #269476

#TimeUsernameProblemLanguageResultExecution timeMemory
269476sean9892화살표 그리기 (KOI18_arrowH)C++14
100 / 100
117 ms7612 KiB
#include<bits/stdc++.h> using namespace std; vector<int> v[100010]; set<int> s; int main(void){ ios::sync_with_stdio(0);cin.tie(0); int n; cin>>n; for(int i=0;i<n;i++){ int x,y; cin>>x>>y; v[y].push_back(x); s.insert(y); } long long sum=0; for(int c:s){ sort(v[c].begin(),v[c].end()); if(v[c].size()==1)continue; auto& w=v[c]; sum+=1ll*w[1]-w[0]+w[w.size()-1]-w[w.size()-2]; for(int i=1;i<w.size()-1;i++){ sum+=min(w[i]-w[i-1],w[i+1]-w[i]); } } cout<<sum; }

Compilation message (stderr)

arrow.cpp: In function 'int main()':
arrow.cpp:23:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   for(int i=1;i<w.size()-1;i++){
      |               ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...