Submission #874458

# Submission time Handle Problem Language Result Execution time Memory
874458 2023-11-17T04:51:59 Z Darren0724 Treatment Project (JOI20_treatment) C++17
35 / 100
3000 ms 7504 KB
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false);cin.tie(0);
#define int long long
#define all(x) x.begin(), x.end()
#define x first
#define y second
const int N=150005;
const int INF=1e18;
struct st{
    int t,l,r,c;
};
int32_t main() {
    int m,n;cin>>m>>n;
    vector<st> v(n);
    for(int i=0;i<n;i++){
        int a,b,c,d;cin>>a>>b>>c>>d;
        v[i]={a,b,c,d};
    }
    vector<int> dis(n,INF);
    priority_queue<pair<int,int>> pq;
    for(int i=0;i<n;i++){
        if(v[i].l==1){
            dis[i]=v[i].c;
            pq.push({-v[i].c,i});
        }
    }
    while(pq.size()){
        auto [d,i]=pq.top();
        pq.pop();
        d=-d;
        if(d!=dis[i]){
            continue;
        }
        for(int j=0;j<n;j++){
            if(j==i){
                continue;
            }
            if(abs(v[i].t-v[j].t)<=v[i].r-v[j].l+1){
                if(dis[j]>dis[i]+v[j].c){
                    dis[j]=dis[i]+v[j].c;
                    pq.push({-dis[j],j});
                }
            }
        }
    }
    int ans=INF;
    for(int i=0;i<n;i++){
        //cout<<dis[i]<<endl;
        if(v[i].r==m){
            ans=min(ans,dis[i]);
        }
    }
    cout<<(ans==INF?-1:ans)<<endl;
    

    return 0;
}
/*
10 5
1 5 10 3
1 1 6 1
1 2 8 3
1 6 10 4
1 1 3 1
*/
# Verdict Execution time Memory Grader output
1 Execution timed out 3098 ms 7504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 360 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 436 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 360 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 436 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 72 ms 856 KB Output is correct
21 Correct 73 ms 604 KB Output is correct
22 Correct 41 ms 604 KB Output is correct
23 Correct 28 ms 600 KB Output is correct
24 Correct 80 ms 792 KB Output is correct
25 Correct 50 ms 604 KB Output is correct
26 Correct 42 ms 600 KB Output is correct
27 Correct 43 ms 600 KB Output is correct
28 Correct 74 ms 856 KB Output is correct
29 Correct 42 ms 604 KB Output is correct
30 Correct 6 ms 600 KB Output is correct
31 Correct 6 ms 604 KB Output is correct
32 Correct 131 ms 1028 KB Output is correct
33 Correct 82 ms 860 KB Output is correct
34 Correct 76 ms 808 KB Output is correct
35 Correct 130 ms 988 KB Output is correct
36 Correct 85 ms 972 KB Output is correct
37 Correct 65 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3098 ms 7504 KB Time limit exceeded
2 Halted 0 ms 0 KB -