結果
| 問題 |
No.2835 Take and Flip
|
| コンテスト | |
| ユーザー |
Pres1dent
|
| 提出日時 | 2024-08-09 21:50:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 126 ms / 2,000 ms |
| コード長 | 349 bytes |
| コンパイル時間 | 1,946 ms |
| コンパイル使用メモリ | 197,352 KB |
| 最終ジャッジ日時 | 2025-02-23 21:32:33 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n; cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
sort(a.begin(), a.end());
ll y = 0, x = 0;
for (int i = 0; i < n / 2; i++) {
y += -a[i];
}
for (int i = n / 2; i < n; i++) {
x += a[i];
}
cout << x - y << endl;
}
Pres1dent