Submission #167331

#TimeUsernameProblemLanguageResultExecution timeMemory
167331Atill83Segway (COI19_segway)C++14
100 / 100
363 ms26488 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define endl '\n' using namespace std; const long long INF = (long long) 1e18; const int mod = (int) 1e9+7; const int MAXN = (int) 3e5+5; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; ll n; bool acc[305]; int sure[305][MAXN]; int open[MAXN]; int seg[MAXN][3]; int tree[MAXN]; void upd(int yer){ for(; yer <= 15000; yer += (yer&-yer)){ tree[yer]++; } } int get(int yer){ int res = 0; for(; yer > 0; yer -= (yer&-yer)) res += tree[yer]; return res; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); #ifdef Local freopen("../IO/int.txt","r",stdin); freopen("../IO/out.txt","w",stdout); #endif cin>>n; for(int i = 0; i < n; i++){ cin>>seg[i][0]>>seg[i][1]>>seg[i][2]; } int m; cin>>m; for(int i = 0; i < m; i++){ int yer; cin>>yer; acc[yer] = 1; } for(int i = 0; i < 300; i++){ int wc = (i < 100 ? 0 : (i < 200 ? 1 : 2)); for(int j = 0; j < n; j++){ if(open[j]){ open[j]--; sure[i + 1][j] = sure[i][j] + 1; }else{ if(acc[i]){ open[j] = (get(sure[i][j] - 1))%20; //cout<<i<<" "<<j<<" "<<open[j]<<endl; if(open[j]){ open[j]--; sure[i + 1][j] = sure[i][j] + 1; }else{ sure[i + 1][j] = sure[i][j] + seg[j][wc]; } }else{ sure[i + 1][j] = sure[i][j] + seg[j][wc]; } } } for(int j = 0; j < 15005; j++){ tree[j] = 0; } for(int j = 0; j < n; j++){ upd(sure[i + 1][j]); } } for(int i = 0; i < n; i++){ cout<<sure[300][i]<<endl; } #ifdef Local cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...