結果
| 問題 |
No.2835 Take and Flip
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-09 21:22:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 41 ms / 2,000 ms |
| コード長 | 411 bytes |
| コンパイル時間 | 1,748 ms |
| コンパイル使用メモリ | 197,900 KB |
| 最終ジャッジ日時 | 2025-02-23 21:12:31 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
vector<int> A(N);
for(auto &a : A) cin >> a;
sort(A.begin(),A.end());
int l = 0,r = N-1;
long long answer = 0;
while(l <= r){
answer += A.at(r--);
if(l > r) break;
answer += A.at(l++);
}
cout << answer << "\n";
}