結果

問題 No.973 余興
ユーザー amaridekinaiamaridekinai
提出日時 2020-01-17 22:53:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 817 bytes
コンパイル時間 1,953 ms
コンパイル使用メモリ 166,412 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-08 06:08:31
合計ジャッジ時間 3,406 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 3 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 3 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 3 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 3 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,380 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 WA -
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 3 ms
4,376 KB
testcase_32 AC 3 ms
4,380 KB
testcase_33 AC 3 ms
4,380 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 3 ms
4,376 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 WA -
testcase_45 AC 2 ms
4,380 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 3 ms
4,376 KB
testcase_49 AC 3 ms
4,376 KB
testcase_50 WA -
testcase_51 AC 3 ms
4,380 KB
testcase_52 AC 4 ms
4,380 KB
testcase_53 WA -
testcase_54 AC 3 ms
4,376 KB
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){ 
  
  ll N,X; cin >> N >> X;
  
  vector<ll> a(N);
  
  for(ll i = 0; i < N; i++){ cin >> a[i];}
  
  ll left = 0; ll right = N-1; //現在食べられる部分を指す
  
  int turn = 0;
  
  while( right - left > 1){ //二分探索ではない
    
    ll cnt1 = 0,cnt2 = 0;
    ll res1 = 0,res2 = 0;
    
    ll l = left;
    
    while( l < N && res1+a[l] <= X && right > l){ res1 += a[l]; l++; cnt1++;}
    
    ll r = right;
    
    while( r >= 0 && res2+a[r] <= X && r > left ){ res2 += a[r]; r--; cnt2++;}
    
    if( cnt1 >= cnt2){ //左を食べる
      left = l;
    }
    else{
      right = r;
    }
  
  
  turn++;
    
  }
  
  if( turn % 2 == 1 ){ cout <<"A" << endl;}
  else{ cout << "B" << endl;}
  
  return 0;
}
0