結果
問題 | No.507 ゲーム大会(チーム決め) |
ユーザー |
|
提出日時 | 2020-07-31 03:52:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 479 bytes |
コンパイル時間 | 2,194 ms |
コンパイル使用メモリ | 197,680 KB |
最終ジャッジ日時 | 2025-01-12 08:30:57 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | int n,m; scanf("%d%d",&n,&m); | ~~~~~^~~~~~~~~~~~~~ main.cpp:10:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | rep(i,n) scanf("%d",&a[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>#define rep(i,n) for(int i=0;i<(n);i++)using namespace std;int main(){int n,m; scanf("%d%d",&n,&m);vector<int> a(n);rep(i,n) scanf("%d",&a[i]);sort(a.begin()+1,a.end());int lo=0,hi=n;while(hi-lo>1){int mi=(lo+hi)/2;int sum=a[0]+a[mi],cnt=0;for(int i=1,j=n-1;;i++,j--){while(i<j && a[i]+a[j]<=sum) i++;if(i>=j) break;cnt++;}if(cnt<m) hi=mi;else lo=mi;}printf("%d\n",hi==n?-1:a[hi]);return 0;}