QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#486066 | #7523. Partially Free Meal | duckindog | RE | 0ms | 3820kb | C++23 | 789b | 2024-07-21 15:38:56 | 2024-07-21 15:38:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 10'000 + 10;
int n;
struct Price {
int a, b;
friend istream& operator >> (istream& is, auto& rhs) {
return is >> rhs.a >> rhs.b;
}
} p[N];
long long f[N], mi[N];
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for (int i = 1; i <= n; ++i) cin >> p[i];
sort(p + 1, p + n + 1, [&](const auto& a, const auto& b) { return a.b < b.b; });
memset(f, 15, sizeof f);
memset(mi, 15, sizeof mi);
f[0] = mi[0] = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= i; ++j) f[j] = min(f[j], mi[j - 1] + p[i].a + p[i].b);
for (int j = i; j >= 1; --j) mi[j] = min(mi[j], mi[j - 1] + p[i].a);
}
for (int i = 1; i <= n; ++i) cout << f[i] << "\n";
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
input:
3 2 5 4 3 3 7
output:
7 11 16
result:
ok 3 lines
Test #2:
score: -100
Runtime Error
input:
200000 466436993 804989151 660995237 756645598 432103296 703610564 6889895 53276988 873617076 822481192 532911431 126844295 623111499 456772252 937464699 762157133 708503076 786039753 78556972 5436013 582960979 398984169 786333369 325119902 930705057 615928139 924915828 506145001 164984329 208212435...