結果

問題 No.2693 Sword
ユーザー VvyLwVvyLw
提出日時 2024-03-22 22:46:35
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,247 bytes
コンパイル時間 1,157 ms
コンパイル使用メモリ 99,132 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-03-22 22:46:55
合計ジャッジ時間 2,445 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 5 ms
6,676 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 4 ms
6,676 KB
testcase_16 AC 5 ms
6,676 KB
testcase_17 AC 5 ms
8,448 KB
testcase_18 AC 3 ms
6,676 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 14 ms
19,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "a.cpp"
#include <vector>
#line 2 "/home/huitloxopetl/CP_Library/C++/core/io/output.hpp"

#include <iostream>
#line 5 "/home/huitloxopetl/CP_Library/C++/core/io/output.hpp"
#include <utility>
#include <map>
#include <set>
#include <deque>
#ifndef TEMPLATE
using i128 = __int128_t;
using u128 = __uint128_t;
#endif
namespace IO {
std::ostream &operator<<(std::ostream &dest, const i128 &value) {
    std::ostream::sentry s(dest);
    if(s) {
        u128 tmp = value < 0 ? -value : value;
        char buffer[128];
        char *d = std::end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while(tmp != 0);
        if(value < 0) {
            --d;
            *d = '-';
        }
        int len = std::end(buffer) - d;
        if(dest.rdbuf() -> sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}
template <class T, class U> std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &p){ os << p.first << ' ' << p.second; return os; }
template <class T, size_t N> std::ostream& operator<<(std::ostream &os, const std::array<T, N> &a){ if(a.size()){ os << a.front(); for(auto i=a.begin(); ++i!=a.end();){ os << ' ' << *i; } } return os; }
template <class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &v){ if(v.size()){ os << v.front(); for(auto i=v.begin(); ++i!=v.end();){ os << ' ' << *i; } } return os; }
template <class K, class V> std::ostream& operator<<(std::ostream &os, const std::map<K, V> &m){ if(m.size()){ os << m.begin()->first << ' ' << m.begin()->second; for(auto i=m.begin(); ++i!=m.end();){ os << '\n' << i->first << ' ' << i->second; } } return os; }
template <class T> std::ostream& operator<<(std::ostream &os, const std::set<T> &st){ if(st.size()){ os << *st.begin(); for(auto i=st.begin(); ++i!=st.end();){ os << ' ' << *i; } } return os; }
template <class T> std::ostream& operator<<(std::ostream &os, const std::multiset<T> &ms){ if(ms.size()){ os << *ms.begin(); for(auto i=ms.begin(); ++i!=ms.end();){ os << ' ' << *i; } } return os; }
template <class T> std::ostream& operator<<(std::ostream &os, const std::deque<T> &dq){ if(dq.size()){ os << dq.front(); for(auto i=dq.begin(); ++i!=dq.end();){ os << ' ' << *i; } } return os; }
inline void out(){ std::cout << '\n'; }
template <bool flush=false, class T> inline void out(const T& x){ std::cout << x << '\n'; if(flush) std::cout.flush(); }
template <bool flush=false, class Head, class... Tail> inline void out(const Head& head, const Tail&... tail){ std::cout << head << ' '; out<flush>(tail...); }
template <bool flush=false, class T> inline void vout(const T& v){ std::cout << v << '\n'; if(flush) std::cout.flush(); }
template <bool flush=false, class T> inline void vout(const std::vector<T>& v){ for(const auto &el: v) std::cout << el << '\n'; if(flush) std::cout.flush(); }
template <bool flush=false, class Head, class... Tail> inline void vout(const Head& head, const Tail&... tail){ std::cout << head << '\n'; vout<flush>(tail...); }

#define fin(...) do{ out(__VA_ARGS__); return; }while(false)
} // IO

#if local
//https://gist.github.com/naskya/1e5e5cd269cfe16a76988378a60e2ca3
#include <C++/core/io/debug_print.hpp>
#else
#define dump(...) static_cast<void>(0)
#endif

/**
 * @brief 出力
 */
#line 3 "a.cpp"
using namespace IO;
template <class T, class U> inline bool chmax(T& a, const U& b) {
	if(a < b) {
		a = b;
		return true;
	}
	return false;
}
int main() {
	std::cin.tie(nullptr) -> sync_with_stdio(false);
	int n, k;
	int64_t p;
	std::cin >> n >> p >> k;
	const auto chk = [](const __int128_t x) -> bool { return x > int64_t(1e18); };
	std::vector dp(n + 1, std::vector(k + 1, __int128_t(0)));
	dp[0][0] = p;
	for(int i = 0; i < n; ++i) {
		int t, b;
		std::cin >> t >> b;
		for(int j = 0; j < k; ++j) {
			if(t == 1) {
				const auto x = dp[i][j] + b;
				if(chk(x)) {
					std::cout << -1 << '\n';
					std::exit(0);
				}
				chmax(dp[i + 1][j + 1], x);
			} else {
				const auto x = dp[i][j] * 2;
				if(chk(x)) {
					std::cout << -1 << '\n';
					std::exit(0);
				}
				chmax(dp[i + 1][j + 1], x);
			}
			chmax(dp[i + 1][j], dp[i][j]);
		}
	}
	std::cout << dp[n][k] << '\n';
}
0