QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#680259 | #9529. Farm Management | ucup-team3215# | WA | 0ms | 3548kb | C++23 | 910b | 2024-10-26 20:25:47 | 2024-10-26 20:25:47 |
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]);
ans = max(ans, wl - max(s, {}) * int64_t(v[k][0]) + ws);
if (i && 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] - max(s, {})));
}
}
cout << ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3492kb
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: 3548kb
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'