第2回早稲田大学プログラミングコンテスト

Submission #1553349

Source codeソースコード

#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

const int MAX_N = 200000;

//[1, n]
vector<long long> bit(MAX_N + 1, 0);

int sum(int i){
    long long s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, long long x){
    while(i <= MAX_N){
        bit[i] += x;
        //bit[i] = max(bit[i], x);
        i += i & - i;
    }
}

int main(){
    int n, m;
    long long h;
    cin >> n >> m >> h;

    int block = n;
    rep(i,n){
        long long a;
        cin >> a;
        add(i + 1, a);
    }

    rep(j,m){
        string s;
        long long x;
        cin >> s >> x;
        if(s[0] == 'c'){
            int right = block + 5, left = 0;
            while(right - left > 1){
                int mid = (right + left) / 2;
                if(sum(mid) <= x - h) left = mid;
                else right = mid;
            }

            if(left == block + 5 - 1){
                cout << "miss" << endl;
                continue;
            }
            long long seg = sum(left + 1);
            long long total = sum(block + 5);
            if(seg != total && seg < x + h){
                cout << "stop" << endl;
            }else{
                cout << "go" << endl;
                add(left + 1, -bit[left + 1]);
            }
        }else{
            block++;
            add(block, x);
        }
    }
}

Submission

Task問題 G - だるま落とし
User nameユーザ名 noy
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1654 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
small 0 / 20 small/case_000.txt,small/case_002.txt,small/case_003.txt,small/case_005.txt,small/case_006.txt,small/case_007.txt,small/case_008.txt,small/case_009.txt,small/case_010.txt,small/case_011.txt,small/case_012.txt,small/case_013.txt,small/case_014.txt,small/case_015.txt,small/case_016.txt,small/case_017.txt,small/case_018.txt,small/case_019.txt,small/case_020.txt,small/case_021.txt,small/case_022.txt,small/case_023.txt,small/case_024.txt,small/case_025.txt,small/case_026.txt,small/case_027.txt,small/case_028.txt,small/case_029.txt,small/case_030.txt,small/case_031.txt,small/case_032.txt,small/case_033.txt,small/case_034.txt,small/case_035.txt,small/case_036.txt,small/case_037.txt
large 0 / 80 large/case_000.txt,large/case_002.txt,large/case_003.txt,large/case_005.txt,large/case_006.txt,large/case_007.txt,large/case_008.txt,large/case_009.txt,large/case_010.txt,large/case_011.txt,large/case_012.txt,large/case_013.txt,large/case_014.txt,large/case_015.txt,large/case_016.txt,large/case_017.txt,large/case_018.txt,large/case_019.txt,large/case_020.txt,large/case_021.txt,large/case_022.txt,large/case_023.txt,large/case_024.txt,large/case_025.txt,large/case_026.txt,large/case_027.txt,large/case_028.txt,large/case_029.txt,large/case_030.txt,large/case_031.txt,large/case_032.txt,large/case_033.txt,large/case_034.txt,large/case_035.txt,large/case_036.txt,large/case_037.txt,large/large_case_000.txt,large/large_case_001.txt,large/large_case_002.txt,large/large_case_003.txt,large/large_case_004.txt,large/large_case_005.txt,large/large_case_006.txt,large/large_case_007.txt,large/large_case_008.txt,large/large_case_009.txt,large/large_case_010.txt,large/large_case_011.txt,large/large_case_012.txt,large/large_case_013.txt,large/large_case_014.txt,large/large_case_015.txt,large/large_case_016.txt,large/large_case_017.txt,large/large_case_018.txt,large/large_case_019.txt,large/large_case_020.txt,large/large_case_021.txt,large/large_case_022.txt,large/large_case_023.txt,large/large_case_024.txt,large/large_case_025.txt,large/large_case_026.txt,large/large_case_027.txt,large/large_case_028.txt,large/large_case_029.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
large/case_000.txt AC 2 ms 1792 KB
large/case_002.txt AC 2 ms 1792 KB
large/case_003.txt WA
large/case_005.txt WA
large/case_006.txt WA
large/case_007.txt WA
large/case_008.txt WA
large/case_009.txt WA
large/case_010.txt WA
large/case_011.txt WA
large/case_012.txt WA
large/case_013.txt WA
large/case_014.txt WA
large/case_015.txt WA
large/case_016.txt WA
large/case_017.txt WA
large/case_018.txt AC 3 ms 1792 KB
large/case_019.txt AC 4 ms 1792 KB
large/case_020.txt AC 4 ms 1792 KB
large/case_021.txt WA
large/case_022.txt WA
large/case_023.txt WA
large/case_024.txt WA
large/case_025.txt WA
large/case_026.txt WA
large/case_027.txt WA
large/case_028.txt WA
large/case_029.txt WA
large/case_030.txt WA
large/case_031.txt WA
large/case_032.txt WA
large/case_033.txt WA
large/case_034.txt WA
large/case_035.txt WA
large/case_036.txt WA
large/case_037.txt WA
large/large_case_000.txt WA
large/large_case_001.txt WA
large/large_case_002.txt WA
large/large_case_003.txt WA
large/large_case_004.txt WA
large/large_case_005.txt WA
large/large_case_006.txt WA
large/large_case_007.txt WA
large/large_case_008.txt WA
large/large_case_009.txt WA
large/large_case_010.txt AC 110 ms 1792 KB
large/large_case_011.txt AC 232 ms 1920 KB
large/large_case_012.txt WA
large/large_case_013.txt WA
large/large_case_014.txt WA
large/large_case_015.txt WA
large/large_case_016.txt WA
large/large_case_017.txt WA
large/large_case_018.txt WA
large/large_case_019.txt WA
large/large_case_020.txt WA
large/large_case_021.txt WA
large/large_case_022.txt WA
large/large_case_023.txt WA
large/large_case_024.txt WA
large/large_case_025.txt WA
large/large_case_026.txt WA
large/large_case_027.txt WA
large/large_case_028.txt WA
large/large_case_029.txt WA
small/case_000.txt AC 2 ms 1792 KB
small/case_002.txt AC 2 ms 1792 KB
small/case_003.txt WA
small/case_005.txt WA
small/case_006.txt WA
small/case_007.txt WA
small/case_008.txt WA
small/case_009.txt WA
small/case_010.txt WA
small/case_011.txt WA
small/case_012.txt WA
small/case_013.txt WA
small/case_014.txt WA
small/case_015.txt WA
small/case_016.txt WA
small/case_017.txt WA
small/case_018.txt AC 3 ms 1792 KB
small/case_019.txt AC 4 ms 1792 KB
small/case_020.txt AC 4 ms 1792 KB
small/case_021.txt WA
small/case_022.txt WA
small/case_023.txt WA
small/case_024.txt WA
small/case_025.txt WA
small/case_026.txt WA
small/case_027.txt WA
small/case_028.txt WA
small/case_029.txt WA
small/case_030.txt WA
small/case_031.txt WA
small/case_032.txt WA
small/case_033.txt WA
small/case_034.txt WA
small/case_035.txt WA
small/case_036.txt WA
small/case_037.txt WA