QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#353028 | #965. Trade | HKOI0# | WA | 1ms | 3672kb | C++20 | 1.1kb | 2024-03-13 19:52:30 | 2024-03-13 19:52:30 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
using ll = long long;
int INF = 1LL << 60;
const int N = 1e5 + 11, M = 4e3 + 11;
int cur[M], nxt[M];
void solve() {
int n, S; cin >> n >> S;
vector<pair<int, int>> A;
for (int i = 0; i < n; i++) {
int x, y; cin >> x >> y;
A.push_back({x, y});
}
sort(A.begin(), A.end(), [](auto a, auto b){
return a.second > b.second;
});
fill(cur, cur + M, INF); cur[0] = 0;
for (int i = 0; i < n; i++) {
fill(nxt, nxt + M, INF);
nxt[0] = min(nxt[0], cur[0]);
for (int j = 1; j < M; j++) {
nxt[j] = min(nxt[j], cur[j]);
nxt[j] = min(nxt[j], cur[j - 1] + A[i].first + (j - 1) * A[i].second);
}
swap(cur, nxt);
}
int ans = 0;
for (int i = 0; i < M; i++) {
if (cur[i] <= S) ans = i;
}
cout << ans << endl;
}
signed main() {
#ifndef LOCAL
ios::sync_with_stdio(false);
cin.tie(nullptr);
#endif
int T = 1;
// cin >> T;
while (T--) solve();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3664kb
input:
2 5 1 1 10 11
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
2 22 10 1 0 10000
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
1 0 1 0
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3572kb
input:
100 100 27 64 97 65 62 73 4 99 39 28 73 80 22 58 49 47 28 63 8 36 1 98 81 74 22 48 44 1 40 46 28 9 42 18 74 97 14 34 53 58 58 34 35 96 32 82 32 17 36 4 46 79 14 15 82 9 7 56 75 73 95 57 2 10 4 59 25 28 91 71 34 26 6 67 52 48 10 36 69 21 84 28 50 7 50 99 64 92 46 83 25 39 57 96 94 87 53 79 20 75 47 9...
output:
5
result:
wrong answer 1st numbers differ - expected: '6', found: '5'