QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#46072 | #4441. BIT Subway | miaomiaozi | AC ✓ | 63ms | 4632kb | C++17 | 1.8kb | 2022-08-25 13:34:19 | 2022-08-25 13:34:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// https://space.bilibili.com/672346917
#ifndef LOCAL
#define LOG(...) 42
#endif
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long LL;
typedef pair <int, int> PII;
constexpr int inf = 0x3f3f3f3f;
constexpr double EPS = 1e-10;
const double PI = acos(-1);
int multi_cases = 1;
bool ge(double a, double b) {
return a - b > EPS || fabs(a - b) < EPS;
}
void A_SOUL_AvA () {
int n;
cin >> n;
vector <double> a(n);
double now = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (ge(now, 200)) {
now += 0.5 * a[i];
} else if (ge(now, 100)) {
now += 0.8 * a[i];
} else {
now += a[i];
}
}
double tot = 0;
for (int i = 0; i < n; i++) {
if (ge(tot, 200)) {
tot += 0.5 * a[i];
} else if (ge(tot, 100)) {
// >= 100
double diff = (200 - tot) * 4 / 5.;
if (ge(a[i], diff)) {
tot += diff * 0.8;
a[i] -= diff;
i--;
} else {
tot += a[i] * 0.8;
}
} else {
// < 100
double diff = (100 - tot);
if (ge(a[i], diff)) {
tot += diff;
a[i] -= diff;
i--;
} else {
tot += a[i];
}
}
}
cout << tot << " " << now << endl;
}
int main () {
cin.tie(nullptr)->sync_with_stdio(false);
cout << fixed << setprecision(3);
int T = 1;
for (multi_cases && cin >> T; T; T--) {
A_SOUL_AvA ();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 63ms
memory: 4632kb
input:
10 10 20 50 105 200 11 31 88 177 30 122 12 75 200 65 200 200 1 2 3 4 5 6 10 10 95 5 125 200 10 20 70 60 55 7 10 99 126 70 10 32 22 200 199 20 77 10000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
504.500 564.500 473.000 523.000 411.000 411.000 515.000 540.000 5087.500 5087.500 1023956.500 1023962.900 1022476.500 1022481.000 5014830.000 5014855.000 5011888.500 5011908.000 5018160.500 5018176.300
result:
ok 10 lines