結果

問題 No.871 かえるのうた
ユーザー titiatitia
提出日時 2019-08-30 22:38:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 985 bytes
コンパイル時間 2,090 ms
コンパイル使用メモリ 199,816 KB
実行使用メモリ 5,452 KB
最終ジャッジ日時 2023-08-20 09:20:21
合計ジャッジ時間 5,985 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 17 ms
4,380 KB
testcase_13 AC 6 ms
4,384 KB
testcase_14 AC 127 ms
5,356 KB
testcase_15 AC 128 ms
5,452 KB
testcase_16 AC 148 ms
5,272 KB
testcase_17 AC 113 ms
5,136 KB
testcase_18 AC 21 ms
4,376 KB
testcase_19 AC 130 ms
5,256 KB
testcase_20 AC 12 ms
4,380 KB
testcase_21 AC 51 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,384 KB
testcase_25 AC 3 ms
4,384 KB
testcase_26 AC 9 ms
4,376 KB
testcase_27 AC 12 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 45 ms
4,644 KB
testcase_30 AC 84 ms
4,772 KB
testcase_31 AC 4 ms
4,380 KB
testcase_32 AC 69 ms
4,896 KB
testcase_33 AC 99 ms
5,280 KB
testcase_34 AC 24 ms
4,376 KB
testcase_35 AC 61 ms
4,756 KB
testcase_36 AC 84 ms
4,952 KB
testcase_37 AC 56 ms
4,388 KB
testcase_38 AC 125 ms
5,112 KB
testcase_39 AC 117 ms
5,060 KB
testcase_40 AC 48 ms
4,668 KB
testcase_41 AC 2 ms
4,384 KB
testcase_42 AC 48 ms
4,732 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 3 ms
4,376 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    int K;
    cin>>N>>K;
    K-=1;

    long long X[N];
    long long A[N];

    for (int i=0;i<N;i+=1){
        cin>>X[i];
    }
    for (int i=0;i<N;i+=1){
        cin>>A[i];
    }

    long long PLUS=X[K]+A[K];
    long long MINUS=X[K]-A[K];
    int ANS[N];

    for (int i=0;i<N;i+=1){
        ANS[i]=0;
    }

    for (int roop=0;roop<100;roop+=1){

        for (int i=0;i<N;i+=1){
            if (X[i]<=PLUS && X[i]>=MINUS){
                ANS[i]=1;
                PLUS=max(PLUS,X[i]+A[i]);
                MINUS=min(MINUS,X[i]-A[i]);
            }
        }

        for (int i=N-1;i>=0;i-=1){
            if (X[i]<=PLUS && X[i]>=MINUS){
                ANS[i]=1;
                PLUS=max(PLUS,X[i]+A[i]);
                MINUS=min(MINUS,X[i]-A[i]);
            }
        }

    }
    int AW=0;
    for (int i=0;i<N;i+=1){
        if (ANS[i]==1){
            AW+=1;
        }
    }

    cout<<AW<<endl;
}
0