#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> X(N), L(N);
for (int &xi : X) {
cin >> xi;
}
for (int &li : L) {
cin >> li;
}
vector<int> idx(N);
iota(idx.begin(), idx.end(), 0);
sort(idx.begin(), idx.end(), [&](int i, int j) { return make_pair(L[i], X[i]) < make_pair(L[j], X[j]); });
/*int64_t INF = 1e15;
vector<vector<int64_t>> dp(N+1, vector<int64_t>(N+1, INF));
for (int i = 0;i < N; ++i) {
dp[i][0] = 0;
}
dp[0][1] = X[idx[0]];
for (int i = 1;i < N; ++i) {
for (int j = 1;j <= N; ++j) {
dp[i][j] = min(dp[i][j], dp[i-1][j]);
if (dp[i-1][j-1] <= L[idx[i]]) dp[i][j] = min(dp[i][j], dp[i-1][j-1] + X[idx[i]]);
}
}
int ans = 0;
while (ans+1 <= N && dp[N-1][ans+1] != INF) {
ans += 1;
}*/
int64_t sum = 0, ans = 0;
while (ans < N && sum <= L[0]) {
sum += X[idx[ans++]];
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
338 ms |
15324 KB |
Output is correct |
2 |
Correct |
373 ms |
15448 KB |
Output is correct |
3 |
Correct |
321 ms |
15520 KB |
Output is correct |
4 |
Correct |
319 ms |
15448 KB |
Output is correct |
5 |
Correct |
318 ms |
15476 KB |
Output is correct |
6 |
Correct |
329 ms |
14308 KB |
Output is correct |
7 |
Correct |
296 ms |
13812 KB |
Output is correct |
8 |
Correct |
316 ms |
14672 KB |
Output is correct |
9 |
Correct |
303 ms |
14524 KB |
Output is correct |
10 |
Correct |
307 ms |
14416 KB |
Output is correct |
11 |
Correct |
280 ms |
13404 KB |
Output is correct |
12 |
Correct |
271 ms |
13396 KB |
Output is correct |
13 |
Correct |
275 ms |
13648 KB |
Output is correct |
14 |
Correct |
270 ms |
13396 KB |
Output is correct |
15 |
Correct |
275 ms |
13552 KB |
Output is correct |
16 |
Correct |
313 ms |
14044 KB |
Output is correct |
17 |
Correct |
296 ms |
13920 KB |
Output is correct |
18 |
Correct |
296 ms |
14168 KB |
Output is correct |
19 |
Correct |
307 ms |
13932 KB |
Output is correct |
20 |
Correct |
293 ms |
13908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |