結果
問題 | No.1267 Stop and Coin Game |
ユーザー |
![]() |
提出日時 | 2020-10-24 00:00:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 869 bytes |
コンパイル時間 | 1,589 ms |
コンパイル使用メモリ | 173,220 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-21 14:01:34 |
合計ジャッジ時間 | 2,823 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 WA * 12 |
ソースコード
#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 1000000007int 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(1){int pos = 0;rep(i,a.size()){if(V-a[i] < 0)pos = 0;else if(V-a[i] < a[0]){pos = i;break;}}V -= a[pos];if(V < 0)break;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;}