結果
| 問題 |
No.507 ゲーム大会(チーム決め)
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-02-22 11:02:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 491 bytes |
| コンパイル時間 | 2,058 ms |
| コンパイル使用メモリ | 193,696 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-02-22 11:02:47 |
| 合計ジャッジ時間 | 3,726 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | for(int i=1;i<=n;i++) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
int a[100005],n,m;
bool c(int x){
int cnt=0;
int X=a[1]+a[x];
for(int i=n;i>=2;i-=2){
if(i==x){
i++;continue;
}else if(i-1==x){
if(a[i]+a[i-2]>X) cnt++;
i--;
continue;
}if(a[i]+a[i-1]>X) cnt++;
}return cnt<m;
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
sort(a+2,a+n+1);
int l=2,r=n,mid;
while(l<=r){
mid=(l+r)/2;
if(c(mid)){
r=mid-1;
}else l=mid+1;
}if(l>n)cout<<-1;
else cout<<a[l];
}
vjudge1