結果
| 問題 |
No.2799 Cut and Eat
|
| コンテスト | |
| ユーザー |
noya2
|
| 提出日時 | 2024-06-17 15:20:27 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 447 bytes |
| コンパイル時間 | 3,240 ms |
| コンパイル使用メモリ | 255,916 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-17 15:21:07 |
| 合計ジャッジ時間 | 4,237 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include<bits/stdc++.h>
int main(){
int n, k; std::cin >> n >> k;
long long sum = 0;
std::vector<int> a(n);
for (auto &x : a){
std::cin >> x;
sum += x;
if (x > k){
x = -(x % 2);
}
}
std::ranges::sort(a, std::greater<int>{});
long long diff = 0;
for (int p = 1; auto &x : a){
diff += p * x;
p *= -1;
}
std::cout << (sum + diff) / 2 << std::endl;
}
noya2