QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#687571 | #9529. Farm Management | SkyEyeController# | WA | 0ms | 3620kb | C++23 | 1.3kb | 2024-10-29 19:46:52 | 2024-10-29 19:46:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int long long
void solve()
{
int n, m;
cin >> n >> m;
vector<array<int, 3>> v(n);
for (auto &[w, l, r] : v)
{
cin >> w >> l >> r;
}
vector<int> downs(n + 1);
vector<int> dt(n + 1);
vector<int> presum(n + 1);
sort(v.rbegin(), v.rend());
int anss = 0;
int noww = 0;
for (int i = 1; i <= n; i++)
{
auto &[w, l, r] = v[i - 1];
downs[i] = (w * l);
anss += downs[i];
noww += l;
dt[i] = dt[i - 1] + (r - l);
presum[i] = presum[i - 1] + (r - l) * w;
}
int finalans = 0;
for (int i = 1; i <= n; i++)
{
int l = 0, r = i;
int tmpans = anss - downs[i];
int res = m - (noww - v[i - 1][1]);
while (l + 1 < r)
{
int mid = (l + r) / 2;
if (dt[mid] <= res)
l = mid;
else
r = mid;
}
tmpans += presum[l];
res -= dt[l];
tmpans += res * v[i - 1][0];
finalans = max(finalans, tmpans);
}
cout << finalans << endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
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: 3620kb
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'