답안 #919476

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919476 2024-01-31T22:15:43 Z amin_2008 Coins (BOI06_coins) C++17
60 / 100
42 ms 9300 KB
#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 = 2e5 + 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();
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Runtime error 39 ms 9300 KB Execution killed with signal 11
8 Runtime error 26 ms 9184 KB Execution killed with signal 11
9 Runtime error 42 ms 9276 KB Execution killed with signal 11
10 Runtime error 26 ms 9128 KB Execution killed with signal 11