提出 #73062461
ソースコード 拡げる
#include <iostream>
#include <vector>
#include <algorithm>
#define fastio cin.tie(0)->sync_with_stdio(0)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
#define sz(x) (int)(x).size()
using namespace std;
typedef long long ll;
int main() {
fastio; int N; cin >> N;
vector<int> v(N);
for (auto& i : v) cin >> i;
sort(all(v));
int M1 = v.back(), M2 = 0, m = v[0], idx = -1;
for (int i = N-1; i >= 0; i--) if (v[i] != M1) {
M2 = v[i]; idx = i; break;
}
vector<int> cand;
auto chk = [&](int st, int en, int val) {
int mid = (st+en)/2;
for (; st <= en; st++, en--) {
if (st == en) {
if (v[st] != val) return false;
}
else if (v[st]+v[en] != val) return false;
}
return true;
};
if (idx == -1) cand.push_back(M1);
else if (chk(0, idx, M1)) cand.push_back(M1);
if (chk(0, N-1, M1+m)) cand.push_back(M1+m);
sort(all(cand));
for (auto i : cand) cout << i << " ";
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - AtCoder Riko |
| ユーザ | Lov34ever |
| 言語 | C++23 (GCC 15.2.0) |
| 得点 | 350 |
| コード長 | 1154 Byte |
| 結果 | AC |
| 実行時間 | 35 ms |
| メモリ | 4648 KiB |
コンパイルエラー
./Main.cpp: In lambda function:
./Main.cpp:23:13: warning: unused variable 'mid' [-Wunused-variable]
23 | int mid = (st+en)/2;
| ^~~
./Main.cpp: In function 'int main()':
./Main.cpp:17:24: warning: variable 'M2' set but not used [-Wunused-but-set-variable]
17 | int M1 = v.back(), M2 = 0, m = v[0], idx = -1;
| ^~
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 350 / 350 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 0_sample_1.txt, 0_sample_2.txt, 0_sample_3.txt |
| All | 0_sample_1.txt, 0_sample_2.txt, 0_sample_3.txt, 1_1.txt, 1_2.txt, 1_3.txt, 1_4.txt, 1_5.txt, 2_1.txt, 2_2.txt, 2_3.txt, 2_4.txt, 3_1.txt, 3_2.txt, 3_3.txt, 3_4.txt, 3_5.txt, 3_6.txt, 4_1.txt, 4_2.txt, 4_3.txt, 4_4.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 0_sample_1.txt | AC | 1 ms | 3452 KiB |
| 0_sample_2.txt | AC | 1 ms | 3536 KiB |
| 0_sample_3.txt | AC | 1 ms | 3596 KiB |
| 1_1.txt | AC | 30 ms | 4584 KiB |
| 1_2.txt | AC | 30 ms | 4572 KiB |
| 1_3.txt | AC | 29 ms | 4576 KiB |
| 1_4.txt | AC | 29 ms | 4648 KiB |
| 1_5.txt | AC | 29 ms | 4580 KiB |
| 2_1.txt | AC | 35 ms | 4576 KiB |
| 2_2.txt | AC | 34 ms | 4492 KiB |
| 2_3.txt | AC | 33 ms | 4456 KiB |
| 2_4.txt | AC | 33 ms | 4648 KiB |
| 3_1.txt | AC | 34 ms | 4488 KiB |
| 3_2.txt | AC | 34 ms | 4516 KiB |
| 3_3.txt | AC | 33 ms | 4572 KiB |
| 3_4.txt | AC | 20 ms | 4580 KiB |
| 3_5.txt | AC | 1 ms | 3512 KiB |
| 3_6.txt | AC | 28 ms | 4488 KiB |
| 4_1.txt | AC | 11 ms | 4524 KiB |
| 4_2.txt | AC | 17 ms | 4444 KiB |
| 4_3.txt | AC | 1 ms | 3436 KiB |
| 4_4.txt | AC | 1 ms | 3536 KiB |