This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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][10005];
int open[305];
int seg[10005][3];
int tree[15005];
void upd(int yer){
for(; yer <= 15000; yer += (yer&-yer)){
tree[yer]++;
}
}
int get(int yer){
int res = 0;
for(; yer; 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];
}
}
//cout<<sure[i + 1][j]<<" ";
}
//cout<<endl;
for(int j = 0; j < 15005; j++){
tree[j] = 0;
}
for(int j = 0; j < n; j++){
int wc = (i + 1 < 100 ? 0 : (i + 1 < 200 ? 1 : 2));
upd(sure[i + 1][j] + (open[j] ? 1 : seg[j][wc]));
}
}
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |