# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
926551 |
2024-02-13T09:25:06 Z |
parlimoos |
Coins (BOI06_coins) |
C++14 |
|
62 ms |
6784 KB |
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'
int n , k;
vector<ll> a;
bool has[500000];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for(int i = 0 ; i < n ; i++){
int d;
cin >> d >> has[i];
a.pb(d);
}
ll o = 0 , cnt = 0;
for(int i = 0 ; i < n ; i++){
if(has[i]) continue;
if(i < n - 1){
if(o + a[i] < a[i + 1]) o += a[i] , cnt++;
}else{
if(o + a[i] < k) o += a[i] , cnt++;
}
}
cout << cnt << endl << k - o;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 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 |
Correct |
60 ms |
6784 KB |
Output is correct |
8 |
Incorrect |
59 ms |
6100 KB |
Output isn't correct |
9 |
Correct |
62 ms |
6608 KB |
Output is correct |
10 |
Correct |
60 ms |
5076 KB |
Output is correct |