#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
vector<int> a, vis;
int n;
int f(int x) {
int cnt = 0;
for (int i = n - 1; i >= 0; i--) {
if (x >= a[i] and vis[a[i]] == 0) cnt++;
while (x >= a[i]) x -= a[i];
}
return cnt;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int k; cin >> n >> k;
a.resize(n), vis.resize(n);
for (int i = 0; i < n; i++) cin >> a[i] >> vis[i];
int cnt = 0, ans = 0;
for (int l = k - 1; l >= 1; l--) {
//cout << l << ' ';
int x = f(l);
if (x > cnt) cnt = x, ans = l;
}
cout << cnt << '\n' << k - ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Incorrect |
4 ms |
464 KB |
Output isn't correct |
3 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
4 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
5 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
6 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
7 |
Runtime error |
60 ms |
14228 KB |
Execution killed with signal 11 |
8 |
Runtime error |
62 ms |
14208 KB |
Execution killed with signal 11 |
9 |
Runtime error |
66 ms |
14336 KB |
Execution killed with signal 11 |
10 |
Runtime error |
62 ms |
13904 KB |
Execution killed with signal 11 |