QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#678182 | #9529. Farm Management | ucup-team5008# | WA | 0ms | 1644kb | C++23 | 1.1kb | 2024-10-26 14:13:07 | 2024-10-26 14:13:09 |
Judging History
answer
#include <cstdio>
#include <algorithm>
const int N = 100000;
int n;
std::pair<int, int> mx_l[N];
long long m;
std::pair<int, std::pair<int, int> > a[N];
int main() {
scanf("%d%lld", &n, &m);
for (int i = 0; i < n; ++i) scanf("%d%d%d", &a[i].first, &a[i].second.first, &a[i].second.second);
std::sort(a, a + n);
long long ans = 0, sli = 0, sum = 0;
for (int i = 0; i < n; ++i) {
sli += a[i].second.first;
mx_l[i + 1] = std::max(mx_l[i], std::make_pair(a[i].second.first, -a[i].first));
sum += (long long)a[i].second.first * a[i].first;
}
for (int k = n; k >= 0; --k) {
if (k != n) {
sli += a[k].second.second - a[k].second.first;
sum += (long long)(a[k].second.second - a[k].second.first) * a[k].first;
}
if (k > 0 && sli - mx_l[k - 1].first <= m) {
long long sum1 = sum + (long long)mx_l[k - 1].first * mx_l[k - 1].second, save = m - sli + mx_l[k - 1].first;
sum1 += (long long)a[k - 1].first * std::min(save, (long long)a[k - 1].second.second - a[k - 1].second.first);
ans = std::max(ans, sum1);
}
if (k < n && sli <= m) {
ans = std::max(ans, sum + (long long)a[n - 1].first * (m - sli));
}
}
printf("%lld\n", ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 1596kb
input:
5 17 2 3 4 6 1 5 8 2 4 4 3 3 7 5 5
output:
109
result:
ok single line: '109'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 1644kb
input:
12 62 503792 9 10 607358 1 3 600501 10 10 33249 4 4 774438 6 6 197692 3 6 495807 8 8 790225 5 9 77272 3 8 494819 4 9 894779 3 9 306279 5 6
output:
33995523
result:
wrong answer 1st lines differ - expected: '35204500', found: '33995523'