結果
問題 | No.2693 Sword |
ユーザー |
|
提出日時 | 2024-03-22 21:52:27 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,132 bytes |
コンパイル時間 | 2,624 ms |
コンパイル使用メモリ | 245,720 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 11:20:52 |
合計ジャッジ時間 | 3,436 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
ソースコード
// #pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> // #include <x86intrin.h> using namespace std; #if __cplusplus >= 202002L using namespace numbers; #endif template<class T> T &ctmin(T &x){ return x; } template<class T, class Head, class ...Tail> T &ctmin(T &x, const Head &h, const Tail &... t){ return ctmin(x = min<T>(x, h), t...); } template<class T> T &ctmax(T &x){ return x; } template<class T, class Head, class ...Tail> T &ctmax(T &x, const Head &h, const Tail &... t){ return ctmax(x = max<T>(x, h), t...); } int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(ios::badbit | ios::failbit); int n, k; long long init; cin >> n >> init >> k; const long long minf = -4e18, th = 1e18; vector<long long> dp(k + 1, minf); dp[0] = init; for(auto i = 0; i < n; ++ i){ int type, delta; cin >> type >> delta; if(type == 1){ for(auto x = k; x >= 1; -- x){ ctmax(dp[x], min(th + 1, dp[x - 1] + delta)); } } else{ for(auto x = k; x >= 1; -- x){ ctmax(dp[x], min(th + 1, 2 * dp[x - 1])); } } } dp[k] > th ? cout << "-1\n" : cout << dp[k] << "\n"; return 0; } /* */