QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#46072#4441. BIT SubwaymiaomiaoziAC ✓63ms4632kbC++171.8kb2022-08-25 13:34:192022-08-25 13:34:22

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-25 13:34:22]
  • 评测
  • 测评结果:AC
  • 用时:63ms
  • 内存:4632kb
  • [2022-08-25 13:34:19]
  • 提交

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