結果
問題 | No.2799 Cut and Eat |
ユーザー |
|
提出日時 | 2024-06-29 01:51:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,180 bytes |
コンパイル時間 | 2,460 ms |
コンパイル使用メモリ | 192,612 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-29 01:52:04 |
合計ジャッジ時間 | 3,408 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
// {{{1 extern "C" int __lsan_is_turned_off() { return 1; } #include <bits/stdc++.h> using namespace std; #include <tr2/dynamic_bitset> using namespace tr2; #include <ext/pb_ds/assoc_container.hpp> #define ll long long #define inf 0x3f3f3f3f #define infl 0x3f3f3f3f3f3f3f3fll #include <assert.h> #ifdef DEBUG #define dprintf(args...) fprintf(stderr,args) #endif #ifndef DEBUG #define dprintf(args...) 69 #endif #define all(x) (x).begin(), (x).end() struct cintype { template<typename T> operator T() { T x; cin>>x; return x; } }; // 1}}} cintype in; int main() { int n=in,k=in; vector<int> a(n);for(auto&x:a)x=in; sort(all(a));reverse(all(a)); int turn=0; ll ans=0; for(auto x:a) { if(x<=k) { if(turn==0) ans+=x; turn^=1; } } while(a.size()&&a.back()<=k) a.pop_back(); for(auto x:a)if(~x&1) { ans+=x/2; turn^=1; } for(auto x:a) if(x&1) { if(turn==0)ans+=x/2; else ans+=x/2+1; turn^=1; } printf("%lld\n",ans); }