제출 #1050179

#제출 시각아이디문제언어결과실행 시간메모리
1050179vjudge1Art Exhibition (JOI18_art)C++17
0 / 100
0 ms344 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int int main() { int n; cin>>n; vector<pair<ll,ll>> v; ll s=0; for(int i=0; i<n; i++) { ll t1,t2; cin>>t1>>t2; s+=t2; v.push_back({t1,0-t2}); } sort(v.begin(),v.end()); for(int i=0; i<v.size(); i++) v[i].second=0-v[i].second; ll mn=0,mx=n-1,fmn=0,fmx=n-1; s-=v[mx].first-v[mn].first; ll s2=s; while(fmn<mx) { //cout<<"currently "<<mn<<' '<<mx<<' '<<s<<'\n'; ll tans=s; for(int j=mn; j<=fmn; j++) { //cout<<tans<<"+=("<<v[j+1].first<<"-"<<v[j].first<<")-"<<v[j].second<<"="; tans+=(v[j+1].first-v[j].first)-v[j].second; //cout<<tans<<'\n'; } if(tans>s) { mn=fmn+1; s=tans; //cout<<"\n\n"; } //else cout<<"but it didn't matter\n\n"; fmn++; } while(mn<fmx) { //cout<<"currently "<<mn<<' '<<mx<<' '<<s<<'\n'; ll tans=s; for(int j=mx; j>=fmx; j--) { //cout<<tans<<"+=("<<v[j].first<<"-"<<v[j-1].first<<")-"<<v[j].second<<"="; tans+=(v[j].first-v[j-1].first)-v[j].second; //cout<<tans<<'\n'; } if(tans>s) { mx=fmx-1; s=tans; //cout<<"\n\n"; } //else cout<<"but it didn't matter\n\n"; fmx--; } mn=0; mx=n-1; fmn=0; fmx=n-1; while(mn<fmx) { //cout<<"currently "<<mn<<' '<<mx<<' '<<s2<<'\n'; ll tans=s2; for(int j=mx; j>=fmx; j--) { //cout<<tans<<"+=("<<v[j].first<<"-"<<v[j-1].first<<")-"<<v[j].second<<"="; tans+=(v[j].first-v[j-1].first)-v[j].second; //cout<<tans<<'\n'; } if(tans>s2) { mx=fmx-1; s2=tans; //cout<<"\n\n"; } //else cout<<"but it didn't matter\n\n"; fmx--; } while(fmn<mx) { //cout<<"currently "<<mn<<' '<<mx<<' '<<s2<<'\n'; ll tans=s2; for(int j=mn; j<=fmn; j++) { //cout<<tans<<"+=("<<v[j+1].first<<"-"<<v[j].first<<")-"<<v[j].second<<"="; tans+=(v[j+1].first-v[j].first)-v[j].second; //cout<<tans<<'\n'; } if(tans>s2) { mn=fmn+1; s2=tans; //cout<<"\n\n"; } //else cout<<"but it didn't matter\n\n"; fmn++; } cout<<max(s,s2); }

컴파일 시 표준 에러 (stderr) 메시지

art.cpp: In function 'int main()':
art.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0; i<v.size(); 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...