結果
問題 | No.2693 Sword |
ユーザー |
![]() |
提出日時 | 2024-03-22 21:51:06 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 584 bytes |
コンパイル時間 | 2,545 ms |
コンパイル使用メモリ | 202,848 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 11:19:29 |
合計ジャッジ時間 | 2,755 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h>using namespace std;template<class T> bool chmax(T &a, const T &x) { return x > a ? a = x, true : false; }int main() {int N, K;long long P;cin >> N >> P >> K;constexpr long long inf = 1e18;vector<long long> dp(K+1, -inf);dp[0] = P;while (N--) {int T, B;cin >> T >> B;vector<long long> _dp = dp;for (int k = 1; k <= K; ++k) {chmax(_dp[k], dp[k-1] * T + B);if (_dp[k] > inf) {cout << -1 << endl;return 0;}}dp = move(_dp);}cout << dp[K] << endl;return 0;}