結果
| 問題 |
No.2835 Take and Flip
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-09-28 15:43:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 59 ms / 2,000 ms |
| コード長 | 499 bytes |
| コンパイル時間 | 776 ms |
| コンパイル使用メモリ | 72,248 KB |
| 最終ジャッジ日時 | 2025-02-24 13:58:10 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxN = 2e5+5;
ll N;
ll A[maxN];
int main()
{
ios::sync_with_stdio(0);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> N;
for(int i=1;i<=N;i++)
cin >> A[i];
sort(A+1,A+1+N);
ll i=1,j=N;
ll ans = 0;
while(i<=j)
{
ans += A[i];
i++;
if(i>j) break;
ans = ans + A[j];
j--;
}
cout << ans << endl;
return 0;
}
vjudge1