結果
問題 | No.2799 Cut and Eat |
ユーザー |
![]() |
提出日時 | 2025-01-11 17:55:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 530 bytes |
コンパイル時間 | 2,505 ms |
コンパイル使用メモリ | 80,144 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-11 17:55:57 |
合計ジャッジ時間 | 2,057 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; int main(){ int i,n,k; cin >> n >> k; vector<ll> a; ll ans = 0; for(i=0;i<n;i++){ ll x; cin >> x; if(x<=k){ a.push_back(x); }else if(x&1){ a.push_back(-1); ans += (x + 1)/2; }else{ a.push_back(0); ans += x/2; } } sort(a.rbegin(),a.rend()); for(i=0;i<n;i+=2) ans += a[i]; cout << ans << "\n"; }