結果
| 問題 |
No.507 ゲーム大会(チーム決め)
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-02-26 20:13:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 3,000 ms |
| コード長 | 623 bytes |
| コンパイル時間 | 1,727 ms |
| コンパイル使用メモリ | 162,676 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-02-26 20:13:42 |
| 合計ジャッジ時間 | 3,428 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:22:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | FL(i,1,n) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
#define FL(i,a,b) for(int i=(a);i<=(b);i++)
#define FR(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long
using namespace std;
const int MAXN = 1e5 + 10;
int n,m;
int a[MAXN],b[MAXN],cnt=0;
bool check(int mid){
cnt=0;
FL(i,2,n) if(i!=mid) b[++cnt]=a[i];
int j=1,res=0;
FR(i,cnt,1){
while(j<i&&b[j]+b[i]<=a[1]+a[mid]) j++;
if(j>=i) break;
res++,j++;
}
return (res<m);
}
int main(){
scanf("%d%d",&n,&m);
FL(i,1,n) scanf("%d",&a[i]);
sort(a+2,a+n+1);
int l=2,r=n,ans=-1;
while(l<=r){
int mid=(l+r)>>1;
if(check(mid)) ans=a[mid],r=mid-1;
else l=mid+1;
}
printf("%d\n",ans);
}
vjudge1