Submission #167330

# Submission time Handle Problem Language Result Execution time Memory
167330 2019-12-07T11:59:30 Z Atill83 Segway (COI19_segway) C++14
40 / 100
171 ms 12632 KB
#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[10005];
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 > 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 time Memory Grader output
1 Correct 5 ms 1660 KB Output is correct
2 Correct 7 ms 1912 KB Output is correct
3 Correct 12 ms 2552 KB Output is correct
4 Correct 30 ms 5240 KB Output is correct
5 Incorrect 171 ms 12632 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1656 KB Output is correct
2 Correct 6 ms 1656 KB Output is correct
3 Correct 5 ms 1656 KB Output is correct
4 Correct 5 ms 1656 KB Output is correct
5 Correct 6 ms 1656 KB Output is correct
6 Correct 6 ms 1656 KB Output is correct
7 Correct 6 ms 1656 KB Output is correct
8 Correct 7 ms 1784 KB Output is correct
9 Correct 8 ms 1840 KB Output is correct
10 Correct 8 ms 1916 KB Output is correct
11 Correct 8 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1660 KB Output is correct
2 Correct 7 ms 1912 KB Output is correct
3 Correct 12 ms 2552 KB Output is correct
4 Correct 30 ms 5240 KB Output is correct
5 Incorrect 171 ms 12632 KB Output isn't correct