답안 #995613

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995613 2024-06-09T13:03:38 Z amine_aroua Pinball (JOI14_pinball) C++17
51 / 100
1000 ms 18780 KB
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
using namespace std;
#define intt long long
#define pb push_back
#define nl '\n'
#define fore(i, y) for(int i = 0; i < y; i++)
#define forr(i, x, y) for(int i = x;i<=y;i++)
#define forn(i, y, x) for(int i = y; i >= x; i--)
const int M = 3e5 + 10;
intt dp[2][M];
intt n , m , o;
vector<tuple<intt , intt , intt,intt>> intervals;
const intt INF = 1e18;
void initDP()
{
    fore(i , 2)
    {
        fore(j , M)
        {
            dp[i][j] = INF;
        }
    }
}
void rakkah()
{
    map<intt ,intt> compress;
    o = 1;
    compress[n] = 1;
    compress[o] = 1;
    forr(i , 1 , m)
    {
        intt a , b , c , d;
        cin>>a>>b>>c>>d;
        compress[a] = compress[b] = compress[c] = 1;
        intervals.pb({a , b , c , d});
    }
    intt cnt = 0;
    for(auto p : compress)
    {
        compress[p.first] = cnt++;
    }
    n = compress[n] ;
    o = compress[o];
    for(auto &[a , b , c , d] : intervals)
    {
        a = compress[a] , b = compress[b] , c = compress[c];
    }
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    initDP();
    cin>>m>>n;
    rakkah();
    intt ans = INF;
    fore(i , m)
    {
        auto [a , b , c ,d] = intervals[i];
        intt cur[2] = {INF , INF};
        if(a == o)
            cur[0] = d;
        if(b == n)
            cur[1] = d;
        forr(x , a , b)
        {
            fore(j , 2)
            {
                cur[j] = min(cur[j] , d + dp[j][x]);
            }
        }
        fore(j , 2)
            dp[j][c] = min(dp[j][c] , cur[j]);
        ans = min(ans , cur[0] + cur[1] - d);
    }
    cout<<(ans >= 1e17 ? -1 : ans)<<nl;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Correct 1 ms 5212 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Correct 1 ms 5212 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 5212 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 2 ms 5212 KB Output is correct
17 Correct 3 ms 5208 KB Output is correct
18 Correct 2 ms 5212 KB Output is correct
19 Correct 3 ms 5212 KB Output is correct
20 Correct 2 ms 5212 KB Output is correct
21 Correct 1 ms 5212 KB Output is correct
22 Correct 2 ms 5208 KB Output is correct
23 Correct 2 ms 5212 KB Output is correct
24 Correct 2 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Correct 1 ms 5212 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 5212 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 2 ms 5212 KB Output is correct
17 Correct 3 ms 5208 KB Output is correct
18 Correct 2 ms 5212 KB Output is correct
19 Correct 3 ms 5212 KB Output is correct
20 Correct 2 ms 5212 KB Output is correct
21 Correct 1 ms 5212 KB Output is correct
22 Correct 2 ms 5208 KB Output is correct
23 Correct 2 ms 5212 KB Output is correct
24 Correct 2 ms 5212 KB Output is correct
25 Correct 54 ms 6868 KB Output is correct
26 Correct 386 ms 10192 KB Output is correct
27 Execution timed out 1029 ms 18780 KB Time limit exceeded
28 Halted 0 ms 0 KB -