結果

問題 No.833 かっこいい電車
ユーザー kamomekamome
提出日時 2019-07-05 00:17:54
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,415 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 30,464 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 05:45:16
合計ジャッジ時間 7,770 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 2 WA * 27 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

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;
            //trains[x].setpoint = trains[x-1].setpoint + trains[x].cool
            t[x].setpoint = t[x-1].setpoint+t[x].setpoint;
        }
        else if(q==2){
            t[x-1].connected=0;
            t[x].setpoint = t[x-1].setpoint-t[x].setpoint;
        }
        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