QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#108109#3563. Treatment Projectbashkort#0 0ms3648kbC++201.1kb2023-05-23 16:34:212024-05-31 13:41:07

Judging History

This is the latest submission verdict.

  • [2024-05-31 13:41:07]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 3648kb
  • [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:34:21]
  • 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);

    for (int i = 0; i < m; ++i) {
        if (s[i].l == 1) {
            dp[i] = s[i].w;
            continue;
        }
        dp[i] = inf;
        for (int j = 0; j < i; ++j) {
            if (s[j].r - s[i].l + 1 >= abs(s[i].t - s[j].t)) {
                dp[i] = min(dp[i], dp[j] + s[i].w);
            }
        }
    }

    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;
}

詳細信息

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: 5
Accepted
time: 0ms
memory: 3648kb

input:

1 1
1000000000 1 1 1000000000

output:

1000000000

result:

ok single line: '1000000000'

Test #20:

score: -5
Wrong Answer
time: 0ms
memory: 3612kb

input:

1000000000 16
6 2 2 1
4 999999997 999999999 4
2 999999997 1000000000 2
3 1 4 3
3 999999997 1000000000 3
5 999999998 999999999 3
6 999999999 999999999 1
2 1 4 2
6 3 999999998 1
999999987 1 1000000000 10
999999986 1 1000000000 10
999999985 1 1000000000 10
4 2 4 4
5 2 3 3
1 999999997 1000000000 1
1 1 4 1

output:

10

result:

wrong answer 1st lines differ - expected: '9', found: '10'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%