QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#631060#3563. Treatment ProjectDimash0 0ms3668kbC++231.2kb2024-10-11 21:44:382024-10-11 21:44:41

Judging History

This is the latest submission verdict.

  • [2024-10-11 21:44:41]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 3668kb
  • [2024-10-11 21:44:38]
  • Submitted

answer

#include <bits/stdc++.h>
    
using namespace std;
    
typedef long long ll;

const int  N = 2e5 + 12, MOD = (int)1e9 + 7;

const ll inf = 1e18;
ll res = inf, dp[N];
int n, m;
vector<array<int, 4>> a;

bool cmp(array<int, 4> x, array<int, 4> y) {
    return make_pair(x[1], x[2]) < make_pair(y[1], y[2]);
}
void test() {
    cin >> n >> m;
    a.resize(m);
    for(int i = 0; i < m; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
    }
    sort(a.begin(), a.end(), cmp);
    for(int i = 0; i < m; i++) {
        dp[i] = inf;
    }
    for(int i = 0; i < m && a[i][1] == 1; i++) {
        dp[i] = 0;
    }
    for(int i = 0; i < m; i++) {
        dp[i] += a[i][3];
        if(a[i][2] == n) {
            res = min(res, dp[i]);
        }
        for(int j = i + 1; j < m; j++) {
            ll inter = a[i][2] - a[j][1] + 1, val = abs(a[i][0] - a[j][0]);
            if(inter >= val) {
                dp[j] = min(dp[j], dp[i]);
            }
        }
    }

    if(res == inf) {
        res = -1;
    }
    cout << res << '\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); 
    
    int t = 1; 
    // cin >> t;
    
    while(t--) 
        test();
    
    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: 3580kb

input:

1 1
1000000000 1 1 1000000000

output:

1000000000

result:

ok single line: '1000000000'

Test #20:

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

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%