답안 #908827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
908827 2024-01-16T23:44:22 Z vjudge1 Pinball (JOI14_pinball) C++17
51 / 100
1000 ms 2592 KB
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll inf=1e18;

struct device{
    ll 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);
            }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[1],min(devs[j].dp[0]+devs[i].d,devs[j].dp[1]+devs[i].d));
            }
        }
        if(devs[i].b==m){
            ans=min(ans,min(devs[i].dp[0],devs[i].dp[1]));
        }
    }
    if(ans==inf) cout<<-1<<endl;
    else cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 6 ms 348 KB Output is correct
18 Correct 5 ms 552 KB Output is correct
19 Correct 6 ms 348 KB Output is correct
20 Correct 6 ms 348 KB Output is correct
21 Correct 2 ms 464 KB Output is correct
22 Correct 4 ms 348 KB Output is correct
23 Correct 2 ms 552 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 6 ms 348 KB Output is correct
18 Correct 5 ms 552 KB Output is correct
19 Correct 6 ms 348 KB Output is correct
20 Correct 6 ms 348 KB Output is correct
21 Correct 2 ms 464 KB Output is correct
22 Correct 4 ms 348 KB Output is correct
23 Correct 2 ms 552 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 490 ms 1288 KB Output is correct
26 Execution timed out 1020 ms 2592 KB Time limit exceeded
27 Halted 0 ms 0 KB -