Submission #1006746

#TimeUsernameProblemLanguageResultExecution timeMemory
1006746De3b0oClosing Time (IOI23_closing)C++17
0 / 100
1091 ms1075972 KiB
#include "closing.h" #include<bits/stdc++.h> #include<random> #define ll long long #define F first #define S second #define in insert #define pb push_back #define ppb pop_back() #define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define cans cout << ans << "\n"; #define yes cout << "Yes" << "\n"; #define no cout << "No" << "\n"; #define pll pair<ll,ll> #define lin cout << "\n"; #define sqr 340 #define mod 1000000007 #define mid ((l+r)/2) #define lc (2*n) #define rc (2*n+1) using namespace std; ll n , x , y , k; vector<pll> adj[200009]; ll vis[200009]; int max_score(int N, int X, int Y, long long K,std::vector<int> U, std::vector<int> V, std::vector<int> W) { n=N; x=X; y=Y; k=K; for(int i = 0 ; n>i ; i++) { adj[i].clear(); vis[i]=0; } for(int i = 0 ; n-1>i ; i++) { adj[U[i]].pb({V[i],W[i]}); adj[V[i]].pb({U[i],W[i]}); } vector<pll> xx , yy; ll d = 0; for(int i = x ; i>=0 ; i--) { xx.pb({d,x-i+1}); if(i) d+=W[i-1]; } d=0; for(int i = y ; n>i ; i++) { yy.pb({d,i-y+1}); if(i<n-1) d+=W[i]; } vector<pll> v; for(auto it1 : xx) { for(auto it2 : yy) { if((it1.F==0&&it1.S==1) || (it2.F==0&&it2.S==1)) continue; v.pb({it1.F+it2.F,it1.S+it2.S}); } } sort(v.begin(),v.end()); ll mx = 0; vector<ll> c; for(auto it : v) { mx=max(mx,it.S); c.pb(mx); } ll ans = 0; for(int i = x ; n>i ; i++) { for(int j = y ; j>=0 ; j--) { ll ans1 = i-x+1 + y-j+1; ll vs[n]; memset(vs,-1,sizeof(vs)); d = 0; for(int h = x ; i>=h ; h++) { vs[h]=max(vs[h],d); if(h<n-1) d+=W[h]; } d=0; for(int h = y ; h>=j ; h--) { vs[h]=max(vs[h],d); if(h) d+=W[h-1]; } ll cost = 0; for(int i = 0 ; n>i ; i++) { if(vs[i]!=-1) cost+=vs[i]; } if(cost>k) continue; ll re = k-cost; ll l = 0 , r = v.size()-1; while(l<=r) { if(v[mid].F>re) r=mid-1; else l=mid+1; } if(l) ans1+=c[l-1]; ans=max(ans,ans1); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...