QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#680248 | #9529. Farm Management | ucup-team3215# | WA | 0ms | 3616kb | C++23 | 914b | 2024-10-26 20:23:36 | 2024-10-26 20:23:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
vector<array<int, 3>> v;
int64_t n, m; cin >> n >> m;
int64_t sl = 0, wl = 0;
for (int i = 0; i < n; ++i) {
int w, l, r; cin >> w >> l >> r;
v.push_back({w, l, r - l});
sl += l, wl += w * l;
}
sort(v.begin(), v.end());
int64_t ans = wl + int64_t(m - sl) * v.back()[0];
int64_t i = n, s = sl - m, ws = 0, pk = -1;
for (int k = 0; k < n; ++k) {
if (pk != -1 && v[pk][1] >= v[k][1]) continue;
pk = k;
while (i && s + v[i - 1][2] <= v[k][1] && v[i - 1][0] > v[k][0]) s += v[--i][2], ws += v[i][0] * int64_t(v[i][2]);
if (s >= 0) ans = max(ans, wl - s * int64_t(v[k][0]) + ws);
if (i && s >= 0 && v[i - 1][0] > v[k][0]) {
ans = max(ans, wl - v[k][1] * int64_t(v[k][0]) + ws + v[i - 1][0] * int64_t(v[k][1] - s));
}
}
cout << ans;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 3608kb
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:
34859047
result:
wrong answer 1st lines differ - expected: '35204500', found: '34859047'