結果

問題 No.833 かっこいい電車
ユーザー kamomekamome
提出日時 2019-07-05 00:24:04
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,816 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 30,380 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-14 23:28:38
合計ジャッジ時間 5,346 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 703 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 4 ms
4,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 25 ms
4,380 KB
testcase_31 AC 1,707 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
int N,Q;
long int x;
int q;
struct train
{
    long long int cool;
    long long int setpoint;
    int connected;
};


int main(){
    scanf("%d %d",&N,&Q);
    struct train t[N];
    for(int i =0;i<N;i++){
        scanf("%lld",&t[i].cool);
        t[i].setpoint=t[i].cool;
        t[i].connected=0;
    }
    for(int i =0;i<Q;i++){
        scanf("%d %ld",&q,&x);
        if(q==1){
            t[x-1].connected=1;
            t[x].setpoint = t[x-1].setpoint+t[x].cool;
            for(int j=x-1;j<N;j++){
                if(t[j].connected == 1){
                    t[j+1].setpoint = t[j].setpoint+t[j+1].cool;
                }
                else{
                    break;
                }
            }
        }
        else if(q==2){
            t[x-1].connected=0;
            t[x].setpoint = t[x-1].setpoint-t[x].cool;
            for(int j=x-1;j<N;j++){
                if(t[j].connected == 1){
                    t[j+1].setpoint = t[j].setpoint+t[j+1].cool;
                }
                else{
                    break;
                }
            }
        }
        else if(q==3){
            t[x-1].cool=t[x-1].cool + 1;
            t[x-1].setpoint=t[x-1].setpoint+1;
            for(int j=x-1;j<N;j++){
                if(t[j].connected == 1){
                    t[j+1].setpoint = t[j].setpoint + t[j+1].cool;
                    //printf("%s","1up");
                }
                else{
                    break;
                }
            }
        }
        else if(q==4){
            long long int res=0;
            while(1){
                if (t[x-1].connected == 0){
                    res=t[x-1].setpoint;
                    break;
                }
                x=x+1;
            }
            printf("%lld\n",res);
        }
    }
    return 0;
}
0