QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#108117#3563. Treatment Projectbashkort#0 0ms3500kbC++201.4kb2023-05-23 16:49:092024-05-31 13:41:17

Judging History

This is the latest submission verdict.

  • [2024-05-31 13:41:17]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 3500kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-23 16:49:09]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

struct Segment {
    int t, l, r, w;
};

constexpr ll inf = 3e18;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;

    vector<Segment> s(m);

    for (auto &[t, l, r, w] : s) {
        cin >> t >> l >> r >> w;
    }

    sort(s.begin(), s.end(), [&](const auto &x, const auto &y) {
        return array{x.r - x.t, y.l} < array{y.r - y.t, y.l};
    });

    vector<ll> dp(m, inf);
    vector<bool> used(m);

    for (int i = 0; i < m; ++i) {
        if (s[i].l == 1) {
            dp[i] = s[i].w;
        }
    }

    for (int _ = 0; _ < m; ++_) {
        int v = -1;
        for (int i = 0; i < m; ++i) {
            if (!used[i] && (v == -1 || dp[v] > dp[i])) {
                v = i;
            }
        }
        dp[v] += s[v].w;
        used[v] = true;
        for (int to = 0; to < m; ++to) {
            if (!used[to] && s[v].r - s[to].l + 1 >= abs(s[v].t - s[to].t)) {
                dp[to] = min(dp[to], dp[v]);
            }
        }
    }

    ll ans = inf;

    for (int i = 0; i < m; ++i) {
        if (s[i].r == n) {
            ans = min(ans, dp[i]);
        }
    }

    if (ans == inf) {
        cout << "-1\n";
    } else {
        cout << ans << '\n';
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

1000000000 100000
1 811370001 811380000 1000000000
1 413190001 413200000 1000000000
1 462480001 462490000 1000000000
1 384860001 384870000 1000000000
1 543220001 543230000 1000000000
1 766300001 766310000 1000000000
1 348890001 348900000 1000000000
1 996350001 996360000 1000000000
1 302700001 302710...

output:


result:


Subtask #2:

score: 0
Wrong Answer

Test #19:

score: 0
Wrong Answer
time: 0ms
memory: 3500kb

input:

1 1
1000000000 1 1 1000000000

output:

2000000000

result:

wrong answer 1st lines differ - expected: '1000000000', found: '2000000000'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%