Submission #525117

# Submission time Handle Problem Language Result Execution time Memory
525117 2022-02-10T18:39:33 Z ali22413836 Coins (BOI06_coins) C++14
60 / 100
39 ms 6524 KB
#include <bits/stdc++.h>
#define  endl "\n"
using namespace std ;
typedef long long ll;
typedef long double ld ;
const int N=2e7;
const ll inf=1e18 ;
const ll mod = 1e9 + 7 ;
ll mypower(ll x, ll y){
    if(y == 0) return 1 ;
    if(y == 1) return x ;
    ll ret = mypower(x , y / 2);
    ret = (ret * ret) % mod;
    if(y % 2) ret = ( ret * x ) % mod ;
    return ret ;
}
ll n , k , a[200009] ;
bool vis[200009] ;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> k ;
    for(int i = 0 ; i < n ;i++){
        cin >> a[i] >> vis[i] ;
    }
    a[n] = k + 1 ;
    ll sum = 0 , ans = 0 ;
    for(int i = 0 ; i  < n ; i++){
        if(vis[i] == 0 && sum + a[i] < a[i + 1]){
            ans++ , sum += a[i] ;
        }
    }
    if(!sum)
        sum = 1 ;
    cout << ans << endl;
    cout << k - sum << endl ;
    return 0 ;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Runtime error 36 ms 6356 KB Execution killed with signal 11
8 Runtime error 39 ms 6524 KB Execution killed with signal 11
9 Runtime error 38 ms 6384 KB Execution killed with signal 11
10 Runtime error 31 ms 6288 KB Execution killed with signal 11