結果
| 問題 |
No.2799 Cut and Eat
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-28 22:27:14 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 878 bytes |
| コンパイル時間 | 3,355 ms |
| コンパイル使用メモリ | 263,088 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 22:27:22 |
| 合計ジャッジ時間 | 4,412 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
// #include <bits/allocator.h> // Temp fix for gcc13 global pragma
// #pragma GCC target("avx2,bmi2,popcnt,lzcnt")
// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif
int main(){
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(ios::badbit | ios::failbit);
int n, k;
cin >> n >> k;
vector<int> l;
array<int, 2> r{};
long long res = 0;
for(auto i = 0; i < n; ++ i){
int x;
cin >> x;
if(x <= k){
l.push_back(x);
}
else{
++ r[x & 1];
res += x >> 1;
}
}
ranges::sort(l | ranges::views::reverse);
for(auto i = 0; i < (int)l.size(); i += 2){
res += l[i];
}
int turn = (int)l.size() & 1;
if(r[0] & 1){
turn ^= 1;
}
while(r[1] --){
if(turn == 1){
++ res;
}
turn ^= 1;
}
cout << res << "\n";
return 0;
}
/*
*/