結果

問題 No.1267 Stop and Coin Game
ユーザー ocvret_ocvret_
提出日時 2020-10-23 23:54:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 858 bytes
コンパイル時間 1,651 ms
コンパイル使用メモリ 173,052 KB
実行使用メモリ 13,760 KB
最終ジャッジ日時 2024-07-21 13:55:52
合計ジャッジ時間 5,540 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16 WA * 4 TLE * 1 -- * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  ll V;
  cin >> n >> V;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  sort(ALL(a));
  {
    ll sum = 0;
    rep(i,n)sum += a[i];
    if(sum <= V){
      cout << "Draw\n";
      return 0;
    }
  }
  int res = 0;
  while(V >= a[0]){
    int pos = -1;
    rep(i,a.size()){
      if(V-a[i] < 0)pos = 0;
      else if(V-a[i] < a[0]){
        pos = i;
        break;
      }
    }
    V -= a[pos];
    for(int i = pos;i < a.size()-1;i++)swap(a[i],a[i+1]);
    a.pop_back();
    res = 1-res;
  }
  cout << (res ? "First\n" : "Second\n");
  



  return 0;
}
0