답안 #995931

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995931 2024-06-10T04:23:08 Z Khanhcsp2 Coins (BOI06_coins) C++14
90 / 100
57 ms 12628 KB
#include<bits/stdc++.h>
#define el '\n'
#define fi first
#define sc second
#define int ll
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int mod=1e9+7;
const int N=5e5+11;
int n, k, a[N], d[N], ans, cnt;
void sol()
{
    cin >> n >> k;
    for(int i=1;i<=n;i++) cin >> a[i] >> d[i];
    for(int i=1;i<=n;i++)
    {
        if(d[i]==1) continue;
        if(i!=n)
        {
            if(ans+a[i]<a[i+1]) ans+=a[i], cnt++;
        }
        else if(ans+a[i]<k) ans+=a[i], cnt++;
    }
    cout << cnt << el;
    cout << k-ans;
}
signed main()
{
//    freopen("divisor.INP", "r", stdin);
//    freopen("divisor.OUT", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin >> t;
    while(t--)
    {
        sol();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 51 ms 12628 KB Output is correct
8 Incorrect 50 ms 12624 KB Output isn't correct
9 Correct 53 ms 12628 KB Output is correct
10 Correct 57 ms 12624 KB Output is correct