結果
| 問題 |
No.2835 Take and Flip
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2024-08-09 21:24:07 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 444 bytes |
| コンパイル時間 | 1,365 ms |
| コンパイル使用メモリ | 98,908 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-08-09 21:24:30 |
| 合計ジャッジ時間 | 2,707 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<ll> a(n);
for(int i = 0;i<n;i++) cin>>a[i];
sort(a.begin(),a.end());
reverse(a.begin(),a.end());
ll ans = 0;
for(int i = 0;i<n;i++){
if(i%2==0) ans += a[i];
else ans += a[i];
}
cout<<ans<<endl;
}
momoyuu