Submission #908818

# Submission time Handle Problem Language Result Execution time Memory
908818 2024-01-16T23:27:16 Z vjudge1 Pinball (JOI14_pinball) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll inf=1e18;

struct device{
    int i, a, b, c, d;
    ll dp[2]={inf, inf};
    bool operator<(const device B)const{
        return b<B.b;
    }
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin>>n>>m;
    vector<device> devs(n);
    for(int i=0; i<n; i++){
        cin>>devs[i].a>>devs[i].b>>devs[i].c>>devs[i].d;
        devs[i].i=i;
    }
    sort(devs.begin(),devs.end());
    ll ans=inf;
    for(int i=0; i<n; i++){
        if(devs[i].a==1) devs[i].dp[0]=devs[i].dp[1]=devs[i].d;
        for(int j=0; j<n; j++){
            if(devs[i].i>devs[j].i && devs[i].a<=devs[j].c && devs[j].c<=devs[i].b){
                devs[i].dp[0]=min(devs[i].dp[0],devs[j].dp[0]+devs[i].d);
                devs[i].dp[1]=min(devs[i].dp[1],devs[j].dp[0]+devs[i].d);
            }else if(devs[j].i>devs[i].i && devs[j].a<=devs[i].c && devs[i].c<=devs[j].b){
                devs[i].dp[1]=min(devs[i].dp[0],min(devs[j].dp[0]+devs[i].d,devs[j].dp[1]+devs[i].d));
            }
        }
        if(devs[i].b==m){
            ans=min(devs[i].dp[0],devs[i].dp[1]);
        }
    }
    if(ans==inf) cout<<-1<<endl;
    else cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -