답안 #167323

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167323 2019-12-07T11:50:25 Z Atill83 Segway (COI19_segway) C++14
0 / 100
7 ms 1912 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[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
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1656 KB Output is correct
2 Incorrect 7 ms 1912 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1656 KB Output is correct
2 Incorrect 7 ms 1912 KB Output isn't correct
3 Halted 0 ms 0 KB -