# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1050179 | 2024-08-09T07:52:35 Z | vjudge1 | Art Exhibition (JOI18_art) | C++17 | 0 ms | 344 KB |
#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); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |