QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#368434 | #4368. Oil | cciafrino# | WA | 213ms | 3820kb | C++20 | 1.3kb | 2024-03-27 04:18:49 | 2024-03-27 04:18:51 |
Judging History
answer
#include<bits/stdc++.h>
using i64 = int64_t;
struct frac_t {
i64 num, den;
frac_t() : num(0), den(1) {}
frac_t(i64 n, i64 d) : num(n), den(d) {
assert(den);
if (den < 0) {
num *= -1;
den *= -1;
}
assert(den > 0);
}
friend bool operator<(const frac_t &a, const frac_t& b) {
return a.num * b.den < b.num * a.den;
}
};
int main() {
using namespace std;
using i64 = int64_t;
cin.tie(nullptr)->sync_with_stdio(false);
int N; cin >> N;
vector<i64> S(N), E(N), Y(N), V;
for (int i = 0; i < N; ++i) {
cin >> S[i] >> E[i] >> Y[i];
if (S[i] > E[i]) swap(S[i], E[i]);
V.push_back(E[i] - S[i]);
}
i64 ans = 0;
for (int i = 0; i < N; ++i) ans = max(ans, V[i]);
for (int z = 0; z < N; ++z) {
for (int steps = 0; steps < 2; ++steps) {
i64 x = 0, y = 0, v = 0;
if (steps & 1) {
x = S[z], y = Y[z], v = V[z];
}
else {
x = E[z], y = Y[z], v = V[z];
}
vector<pair<frac_t, i64>> pts;
for (int i = 0; i < N; ++i) {
if (y == Y[i]) continue;
frac_t lo(S[i] - x, Y[i] - y);
frac_t hi(E[i] - x, Y[i] - y);
pts.emplace_back(lo, -V[i]);
pts.emplace_back(hi, V[i]);
}
sort(pts.rbegin(), pts.rend());
ans = max(ans, v);
for (auto p : pts) {
v += p.second;
ans = max(ans, v);
}
}
}
cout << ans << '\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3588kb
input:
5 100 180 20 30 60 30 70 110 40 10 40 50 0 80 70
output:
200
result:
ok single line: '200'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
3 50 60 10 -42 -42 20 25 0 10
output:
25
result:
ok single line: '25'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
1 -100 180 20
output:
280
result:
ok single line: '280'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
1 -1000000 1000000 1
output:
2000000
result:
ok single line: '2000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
1 -1000000 1000000 1000000
output:
2000000
result:
ok single line: '2000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1 -1000000 -999999 1000000
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
1 1000000 999999 1000000
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
2 -1000 0 200 1 1000 200
output:
1000
result:
ok single line: '1000'
Test #9:
score: -100
Wrong Answer
time: 213ms
memory: 3676kb
input:
1000 737368 429284 959063 -548693 513523 43074 243164 -465669 860567 422975 -244747 588631 -136535 -470055 501433 -580596 -269833 22422 476738 -448258 866889 358773 563858 950905 -923261 208187 66835 -295330 444422 360513 -903435 841952 491761 377801 520064 65247 479135 -307498 426574 -794533 -46924...
output:
485034187
result:
wrong answer 1st lines differ - expected: '490622362', found: '485034187'