結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
vjudge1
|
| 提出日時 | 2025-04-17 17:05:26 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 929 bytes |
| コンパイル時間 | 6,746 ms |
| コンパイル使用メモリ | 173,144 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-04-17 17:05:34 |
| 合計ジャッジ時間 | 6,694 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 1 WA * 29 |
ソースコード
#include <bits/stdc++.h>
#define int long long
#define vi vector<int>
#define debug(x) cout << #x << " = " << x << "\n";
#define vdebug(a) cout << #a << " = "; for(auto x: a) cout << x << " "; cout << "\n";
#define fi first
#define sc second
using namespace std;
void solve() {
int n;
cin >> n;
vector<pair<int,int>> a(n);
for(int i = 0; i < n; i++) {
cin >> a[i].first;
a[i].second = i;
}
if(n <= 2) {
cout << max(a[0].first, a[1].first) << endl; return;
}
if(n == 1) {
cout << a[0].first << endl;
return;
}
sort(a.begin(), a.end(), greater<pair<int,int>>());
if(abs(a[0].second - a[1].second) <= 1) {
cout << a[0].first + a[2].first << endl;
return;
} else {
cout << a[0].first + a[1].first << endl;
return;
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
}
vjudge1