QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#194921 | #7520. Monster Generator | ucup-team296# | TL | 0ms | 3572kb | C++14 | 1.9kb | 2023-09-30 23:39:04 | 2023-11-04 18:36:39 |
Judging History
你现在查看的是最新测评结果
- [2023-11-04 16:34:13]
- hack成功,自动添加数据
- (//qoj.ac/hack/422)
- [2023-11-04 16:28:16]
- hack成功,自动添加数据
- (//qoj.ac/hack/420)
- [2023-09-30 23:39:04]
- 提交
answer
#include <bits/stdc++.h>
#define long int64_t
#define DEBUG
using namespace std;
// @author: pashka
bool lss(long a1, int a2, long b1, int b2) {
return a1 < b1 || (a1 == b1 && a2 < b2);
}
int main() {
ios::sync_with_stdio(false);
int n;
long m;
int64_t _;
cin >> n >> _;
m = _;
vector<long> a(n), da(n), b(n), db(n);
for (int i = 0; i < n; i++) {
cin >> _;
a[i] = _;
cin >> _;
da[i] = _;
cin >> _;
b[i] = _;
cin >> _;
db[i] = _;
}
long res = 0;
for (int t = 0; t <= m; t++) {
vector<long> aa(n);
vector<long> bb(n);
for (int i = 0; i< n; i++) {
aa[i] = a[i] + da[i] * t;
bb[i] = b[i] + db[i] * t;
}
vector<int> r;
{
vector<pair<long, int>> d;
for (int i = 0; i < n; i++) {
if (aa[i] < bb[i]) {
d.emplace_back(aa[i], i);
}
}
sort(d.begin(), d.end());
for (auto p : d) {
r.push_back(p.second);
}
}
{
vector<pair<long, int>> d;
for (int i = 0; i < n; i++) {
if (aa[i] >= bb[i]) {
d.emplace_back(bb[i], i);
}
}
sort(d.rbegin(), d.rend());
for (auto p : d) {
r.push_back(p.second);
}
}
long c = 0;
long s = 0;
for (int i : r) {
c -= aa[i];
s = min(s, c);
c += bb[i];
}
res += -s;
// cout << t << ":\n";
// for (int i = 0; i < n; i++) cout << aa[i] << " " << bb[i] << "\n";
// for (auto x : r) cout << x << " ";
// cout << "\n";
}
cout << (uint64_t) res << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3572kb
input:
3 5 3 1 5 2 4 2 1 3 1 9 100 1
output:
113
result:
ok single line: '113'
Test #2:
score: -100
Time Limit Exceeded
input:
3 100000000 3 1 5 2 4 2 1 3 1 9 100 1