QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#680248#9529. Farm Managementucup-team3215#WA 0ms3616kbC++23914b2024-10-26 20:23:362024-10-26 20:23:37

Judging History

你现在查看的是最新测评结果

  • [2024-10-26 20:23:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-10-26 20:23:36]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'