結果
| 問題 | No.3758 Fan Meeting |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-09 23:22:44 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 595 bytes |
| 記録 | |
| コンパイル時間 | 1,124 ms |
| コンパイル使用メモリ | 218,704 KB |
| 実行使用メモリ | 9,928 KB |
| 最終ジャッジ日時 | 2026-10-09 23:22:52 |
| 合計ジャッジ時間 | 4,905 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 WA * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
int main(void){
cin.tie(nullptr); ios_base::sync_with_stdio(false);
ll i,j;
ll N,S;
cin >> N >> S;
vector<ll> a(N);
REP(i,N){
cin >> a[i];
}
sort(a.begin(),a.end());
if(a[N-1]>=S){
cout << a[N-1] << endl;
return 0;
}
ll p=-1;
S--;
for(i=N-1;i>=0;i--){
if(a[i]<=S){
S-=a[i];
}
else{
p=i;
break;
}
}
if(p==-1){
cout << 1 << endl;
return 0;
}
cout << a[p] << endl;
return 0;
}