Submission #919477

#TimeUsernameProblemLanguageResultExecution timeMemory
919477amin_2008Coins (BOI06_coins)C++17
100 / 100
60 ms11600 KiB
#pragma GCC optimize ("O3") #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // author: amin_2008 typedef long long ll; #define pb push_back #define ins insert #define ts to_string #define sz(x) (int)(x).size() #define mp make_pair #define F first #define S second #define bpc __builtin_popcount #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define lb lower_bound #define ub upper_bound #define ld long double #define endl '\n' #define int ll using namespace std; using namespace __gnu_pbds; using namespace __cxx11; using pii = pair<int, int>; using vi = vector<int>; using vs = vector<string>; using vpii = vector<pii>; using vb = vector<bool>; using vc = vector<char>; using vvi = vector<vi>; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define debug(x) cerr << (#x) << ": " << x << endl const int MOD = 998244353; const int mod = 1e9 + 7; const int inf = 1e18; const int sz = 5e5 + 5; const int N = 18; const int lg = 18; pii a[sz]; void solve() { int n, k; cin >> n >> k; for(int i = 1; i <= n; i++) { cin >> a[i].F >> a[i].S; a[i].S = 1 - a[i].S; } a[n + 1].F = k; int s = 0; int res = 0, maks = k - 1; for(int i = 1; i <= n; i++) { if ( a[i].S and a[i].F + s < a[i + 1].F ) { res++; maks = k - ( a[i].F + s ); s += a[i].F; } } cout << res << endl << maks << endl; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; for(int i = 1; i <= t; i++) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...