Submission #863138

#TimeUsernameProblemLanguageResultExecution timeMemory
863138denniskimOvertaking (IOI23_overtaking)C++17
19 / 100
3 ms16948 KiB
#include "overtaking.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef __int128 lll; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ld, ld> pld; #define MAX 9223372036854775807LL #define MIN -9223372036854775807LL #define INF 0x3f3f3f3f3f3f3f3f #define fi first #define se second #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10); #define sp << " " #define en << "\n" #define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end()) ll n, m, x; ll LL; ll w[2010]; ll S[2010][2010]; ll spd[2010]; vector<pll> qry; void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> SS) { x = X, LL = L; for(ll i = 0 ; i < N ; i++) { if(W[i] <= X) continue; spd[++n] = W[i] - X; S[1][n] = T[i]; } for(ll i = 0 ; i < M ; i++) w[++m] = SS[i]; for(ll i = 1 ; i < m ; i++) { vector<pll> vv; for(ll j = 1 ; j <= n ; j++) vv.push_back({S[i][j], j}); sort(vv.begin(), vv.end()); ll maxx = 0; ll dist = w[i + 1] - w[i]; for(auto &j : vv) { S[i + 1][j.se] = max(S[i][j.se] + dist * spd[j.se], maxx); maxx = max(maxx, S[i + 1][j.se]); } } for(ll i = 1 ; i < m ; i++) { vector<pll> vv; for(ll j = 1 ; j <= n ; j++) vv.push_back({S[i + 1][j], S[i][j]}); sort(vv.begin(), vv.end()); reverse(vv.begin(), vv.end()); for(ll j = 0 ; j < n ; j++) qry.push_back({vv[j].se, vv[j].fi}); } } ll arrival_time(ll Y) { for(auto &i : qry) { if(Y > i.fi) Y = max(Y, i.se); } return Y + x * LL; }
#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...