結果
| 問題 |
No.507 ゲーム大会(チーム決め)
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2017-07-12 09:21:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 440 ms / 3,000 ms |
| コード長 | 1,357 bytes |
| コンパイル時間 | 938 ms |
| コンパイル使用メモリ | 97,108 KB |
| 最終ジャッジ日時 | 2025-01-05 01:31:18 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:25:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | REP (i,n) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;
#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl
int a[100000];
int main(void) {
int i, n, m;
scanf("%d%d",&n,&m);
REP (i,n) scanf("%d",&a[i]);
multiset<int> scores;
REP (i,1,n-1) scores.insert(a[i]);
sort(a+1,a+n);
int l = 0, r = n;
while (l + 1 < r) {
auto st = scores;
int mid = (l + r) / 2;
int score = a[0] + a[mid];
st.erase(st.lower_bound(a[mid]));
int cnt;
REP (cnt,n/2-1) {
int mx = *(--st.end());
st.erase(--st.end());
auto p = st.lower_bound(score - mx + 1);
if (p == st.end()) break;
st.erase(p);
}
if (m < cnt + 1) {
l = mid;
}
else {
r = mid;
}
}
if (r == n)
puts("-1");
else
printf("%d\n",a[r]);
return 0;
}
h_noson