Submission #1284563

#TimeUsernameProblemLanguageResultExecution timeMemory
1284563thelegendary08Overtaking (IOI23_overtaking)C++17
0 / 100
1 ms340 KiB
#include "overtaking.h" #include<bits/stdc++.h> #define int long long #define f0r(i,n) for(int i = 0; i<n; i++) #define pb push_back #define mp make_pair #define vi vector<int> #define vvi vector<vi> #define mii map<int,int> #define pii pair<int,int> #define vpii vector<pii> #define FOR(i, k, n) for(int i = k; i<n; i++) #define vb vector<bool> #define vout(v) for(auto u : v)cout<<u<<' '; cout<<endl; #define ckmax(x, y) x = max(x,y) #define dout(x) cout<<x<<' '<<#x<<endl; #define dout2(a,b) cout<<a<<' '<<#a<<' '<<b<<' '<<#b<<endl using namespace std; int L, N, X, M; vi T, W, S; vvi rch, ex; //sorting station, reaching time void init(signed L, signed N, std::vector<long long> T, std::vector<signed> W, signed X, signed M, std::vector<signed> S) { ::L=L, ::N=N, ::X=X, ::M=M, ::T=T; ::W.resize(N); f0r(i,N)::W[i] = W[i]; ::S.resize(M); f0r(i,M)::S[i] = S[i]; rch.resize(M); f0r(i, M)rch[i].resize(N); ex.resize(M); f0r(i, M)ex[i].resize(N); f0r(i, N)ex[0][i] = T[i], rch[0][i] = T[i]; for(int i = 1; i<M; i++){ f0r(j,N){ // cout<<ac[j][i-1]<<' '<<speed[j]<<' '<<s[i] - s[i-1]<<'\n'; ex[i][j] = rch[i-1][j] + W[j] * (S[i] - S[i-1]); } vpii thing; f0r(j, N){ thing.pb(mp(rch[i-1][j], j)); } sort(thing.begin(), thing.end()); int ptr = 0; int rnmx = 0; f0r(j, N){ if(ptr <= N-1 && thing[ptr].first != thing[j].first){ while(ptr != j){ rnmx = max(rnmx, ex[i][thing[ptr].second]); ptr++; } } rch[i][thing[j].second] = max(rnmx, ex[i][thing[j].second]); } } /* FOR(i, 1, M){ int mx = 0; vpii w; f0r(j, N)w.pb(mp(rch[i-1][j], j)); sort(w.begin(), w.end()); vi que; f0r(j, N)ex[i][j] = rch[i-1][j] + (S[i] - S[i-1]) * W[j]; f0r(j, N){ if(j != 0 && w[j].first != w[j-1].first){ while(!que.empty()){ int k = que.back(), d = w[k].second; mx = max(mx, ex[i][d]); que.pop_back(); } } rch[i][w[j].second] = max(mx, ex[i][w[j].second]); que.pb(j); } } */ // f0r(i, M){ // f0r(j, N)cout<<ex[i][j]<<' '; cout<<'\n'; // } return; } long long arrival_time(long long Y) { set<int>rel; f0r(i, N){ if(T[i] < Y && W[i] > X)rel.insert(i); } // vout(rel); int cur = Y; FOR(i, 1, M){ int mx = cur + X * (S[i] - S[i-1]); for(auto u : rel){ if(rch[i-1][u] < cur){ mx = max(mx, ex[i][u]); } } cur = mx; } return cur; }
#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...