QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#473337 | #8137. 'Ello, and What Are You After, Then? | ucup-team1198# | TL | 881ms | 4196kb | C++14 | 3.2kb | 2024-07-12 02:01:56 | 2024-07-12 02:01:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ld = double;
const ld PI = atan2l(0, -1);
const int K = 100;
const int MAXN = 1e3;
vector<array<int, 3>> arr[MAXN];
const ld EPS = 1e-8;
void solve_() {
int b, c, s;
cin >> b >> c >> s;
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
int m;
cin >> m;
arr[i].resize(m);
for (int j = 0; j < m; ++j) {
cin >> arr[i][j][0] >> arr[i][j][1] >> arr[i][j][2];
}
}
ld l = 0, r = 1e4;
vector<pair<ld, pair<ld, ld>>> opt;
for (int _ = 0; _ < 40; ++_) {
ld a = (l + r) / 2;
bool found = false;
bool found_pos = false;
ld x = 0, y = 1;
array<ld, 2> lft, rgh;
for (int i = 0; i <= K; ++i) {
/**if (y < 0) {
found_pos = true;
break;
}*/
//cerr << x << ',' << y << '\n';
//ld x = cosl(PI / 2 / K * i), y = sinl(PI / 2 / K * i);
pair<ld, pair<ld, ld>> sum(-1, make_pair(-1, -1));
for (int shop = 0; shop < n; ++shop) {
opt.clear();
for (auto elem : arr[shop]) {
ld score = elem[1] * (elem[2] - a);
ld P = x * score + y * c;
ld Q = -y * s;
P *= elem[0];
Q *= elem[0];
opt.push_back(max(make_pair(P, make_pair(score * elem[0], c * elem[0])),
make_pair(Q, make_pair(ld(0), -s * elem[0]))));
}
sort(opt.begin(), opt.end());
pair<ld, pair<ld, ld>> cur(0, make_pair(0, 0));
for (int i = (int)opt.size() - 1; i >= 0; --i) {
if (i >= b || opt[i].first >= 0) {
cur.first += opt[i].first;
cur.second.first += opt[i].second.first;
cur.second.second += opt[i].second.second;
}
}
sum = max(sum, cur);
}
if (sum.first <= EPS) {
found = true;
break;
}
//cerr << sum.first << ' ' << sum.second.first << ',' << sum.second.second << '\n';
if (sum.second.first >= 0 && sum.second.second >= 0) {
found_pos = true;
break;
}
if (sum.second.second >= 0) {
x = sum.second.second;
y = -sum.second.first;
} else {
found_pos = true;
break;
x = -sum.second.second;
y = sum.second.first;
}
}
if (found_pos) {
l = a;
} else if (found) {
r = a;
} else {
l = a;
}
}
ld res = (l + r) / 2;
cout << res << "\n";
}
/// #define MULTITEST
main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
int tst = 1;
#ifdef MULTITEST
cin >> tst;
#endif // MULTITEST
while (tst--) {
solve_();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
input:
0 1 6 2 1 1 1 1 2 1 10 1 1 10 10
output:
7.00000000051659299061
result:
ok found '7.0000000', expected '7.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
2 1 2 1 4 10 2 1 10 1 1 1 10 1 1 1 10
output:
5.90909090988134266809
result:
ok found '5.9090909', expected '5.9090909', error '0.0000000'
Test #3:
score: 0
Accepted
time: 881ms
memory: 4196kb
input:
14 1000 1000 1000 30 113 80 1188 92 145 1074 130 56 1296 139 102 1142 60 76 1317 128 126 1208 73 120 1155 91 89 1197 115 64 979 80 118 592 110 97 556 83 105 578 94 51 848 98 134 757 107 138 1038 105 143 892 92 72 893 88 103 961 87 148 879 105 84 823 85 134 607 100 82 1084 199 58 801 138 85 743 214 1...
output:
1453.36573675649560755119
result:
ok found '1453.3657368', expected '1453.3645790', error '0.0000008'
Test #4:
score: -100
Time Limit Exceeded
input:
8720 713 168 1 30000 1 186 5272 2 53 5132 2 124 5529 2 186 5052 2 82 5342 2 178 5027 1 74 5271 2 154 5506 1 185 5225 2 60 5068 2 85 5179 1 193 5231 1 94 5469 2 168 5317 2 142 5153 2 44 5083 2 71 5318 2 53 5325 1 68 5051 2 53 5424 2 150 5125 2 122 5371 2 126 5171 2 39 5315 2 57 5193 1 130 5203 2 179 ...
output:
5278.03896598470601020381