結果
問題 |
No.2799 Cut and Eat
|
ユーザー |
👑 ![]() |
提出日時 | 2024-06-21 00:33:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 482 bytes |
コンパイル時間 | 2,375 ms |
コンパイル使用メモリ | 199,592 KB |
最終ジャッジ日時 | 2025-02-21 23:35:45 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 RE * 10 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; int main(){ ll N, K; cin >> N >> K; vector<ll> A(N); for (auto &x : A) cin >> x; sort(A.begin(), A.end(), [&](int l, int r){ if (max(l, r) <= K) return l > r; if (r <= K) return false; if (l <= K) return true; return (r % 2 == 1); }); ll ans = 0; for (int i = 0; i < N; i++){ if (A[i] <= K){ if (i % 2 == 0) ans += A[i]; } else{ ans += (A[i] + i % 2) / 2; } } cout << ans << "\n"; }