QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#194921#7520. Monster Generatorucup-team296#TL 0ms3828kbC++141.9kb2023-09-30 23:39:042023-09-30 23:39:04

Judging History

你现在查看的是测评时间为 2023-09-30 23:39:04 的历史记录

  • [2023-11-04 18:36:39]
  • 管理员手动重测本题所有提交记录
  • 测评结果:TL
  • 用时:0ms
  • 内存:3572kb
  • [2023-11-04 17:10:05]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:1ms
  • 内存:3616kb
  • [2023-09-30 23:39:04]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3828kb
  • [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: 3828kb

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

output:


result: