# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
137540 |
2019-07-28T06:22:14 Z |
윤교준(#3280) |
Coins (BOI06_coins) |
C++14 |
|
1000 ms |
7344 KB |
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmin(a,b) (a)=min((a),(b))
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
const int MAXN = 500055;
ll D[MAXN];
int A[MAXN];
bitset<MAXN> B;
ll AnsC = INFLL;
int N, K, Ans;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> N >> K;
for(int i = 1, c; i <= N; i++) {
cin >> A[i] >> c;
B[i] = !c;
}
fill(D+1, D+N+1, INFLL);
for(int i = 1; i <= N; i++) if(B[i]) {
ll t = i == N ? INFLL : A[i+1]-A[i];
for(int k = 1; k <= N; k++) {
if(t <= D[k-1]) break;
upmin(D[k], D[k-1] + A[i]);
}
}
for(int i = 1; i <= N; i++) if(D[i] <= K) {
Ans = i;
AnsC = D[i];
}
cout << Ans << endl << K-AnsC << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Execution timed out |
1056 ms |
7344 KB |
Time limit exceeded |
8 |
Incorrect |
111 ms |
7332 KB |
Output isn't correct |
9 |
Execution timed out |
1051 ms |
7340 KB |
Time limit exceeded |
10 |
Correct |
115 ms |
7288 KB |
Output is correct |