제출 #203293

#제출 시각아이디문제언어결과실행 시간메모리
203293wendy_virgoArt Exhibition (JOI18_art)C++14
30 / 100
1077 ms1120 KiB
#include <bits/stdc++.h> using namespace std; #define taskname "JOI18_art" #define forinc(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define fordec(i, a, b) for (int i = (a), _b = (b); i >= _b; --i) #define foreach(i, x) for (auto &i : x) #define ms(x, n) memset(x, n, sizeof(x)) #define sz(x) int((x).size()) #define all(x) (x).begin(), (x).end() #define uni(x) (x).erase(unique(all(x)), (x).end()) #define fi first #define se second #define pb push_back #define pf push_front template<typename TH> void _dbg(const char* sdbg, TH h) { cerr << sdbg << " = " << h << "\n"; } template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) { while (*sdbg != ',') cerr << *sdbg++; cerr << " = " << h << ","; _dbg(sdbg + 1, t...); } #define db(...) _dbg(#__VA_ARGS__, __VA_ARGS__) #define chkpt cerr << "--- Checkpoint here ---\n"; const int N=5e5+5; int n; int64_t a[N],b[N]; int p[N]; int64_t s[N]; bool Cmp(int x,int y) { return a[x]<a[y]; } void Sub3() { int64_t ans=0; forinc(i,1,n) { p[i]=i; } sort(p+1,p+1+n,Cmp); map<int,int> l,r; forinc(i,1,n) { r[a[p[i]]]=i; s[i]=s[i-1]+b[p[i]]; } fordec(i,n,1) { l[a[p[i]]]=i; } forinc(i,1,n) { forinc(j,i,n) { ans=max(ans,s[r[a[p[j]]]]-s[l[a[p[i]]]-1]-a[p[j]]+a[p[i]]); } } cout<<ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifndef ONLINE_JUDGE // freopen(taskname".INP","r",stdin); #endif // ONLINE_JUDGE cin>>n; forinc(i,1,n) { cin>>a[i]>>b[i]; } Sub3(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...