// #pragma GCC optimize("O3,unroll-loops") #include // #include using namespace std; #if __cplusplus >= 202002L using namespace numbers; #endif template T &ctmin(T &x){ return x; } template T &ctmin(T &x, const Head &h, const Tail &... t){ return ctmin(x = min(x, h), t...); } template T &ctmax(T &x){ return x; } template T &ctmax(T &x, const Head &h, const Tail &... t){ return ctmax(x = max(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 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; } /* */