답안 #955886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955886 2024-03-31T16:11:10 Z vjudge1 Pinball (JOI14_pinball) C++17
51 / 100
316 ms 34780 KB
#include <bits/stdc++.h> 
#include <chrono> 
#include <ext/pb_ds/assoc_container.hpp> 
   
using namespace std;
using namespace __gnu_pbds;
   
template  <typename T > 
using oset = tree < T, null_type, less < T > ,  rb_tree_tag,  tree_order_statistics_node_update > ;
   
#define int long long
       
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) v.begin(),  v.end()
#define rall(v) v.rbegin(),  v.rend()
       
#define endl '\n'

using ll = long long;
using ld = long double;
       
       
#define send ios::sync_with_stdio(false);
#define help cin.tie(0);
       
void solve(int T);
       
const int N = 1e5 + 10;
const int M = 405;
const int SQRT = sqrt(N);
const int LOG = 20;
const int INF = 1e12;
const int MOD = 45678;
const ld EPS = 1e-9;
       
       
int ans;
int n,  m,  q,  l,  r,  x,  y,  mx,  mn;
       
       
int32_t main(){
    send help;
    solve(1);
}

struct SGT{

    vector<int> t;
    int n;
    SGT(int _n){n = _n;
        t.resize(4 * n, INF);
    }

    void modify(int k,int tl,int tr,int p,int v){
        if(tl == tr){
            t[k] = min(t[k],v);
            return;
        }
        int tm = (tl + tr) / 2;
        if(p <= tm)modify(k*2,tl,tm,p,v);
        else modify(k*2+1,tm+1,tr,p, v);
        t[k] = min(t[k*2], t[k*2+1]);
    }

    int query(int k,int tl,int tr,int l,int r){
        if(tr < l || r < tl)return INF;
        if(l <= tl && tr <= r)return t[k];
        int tm = (tl + tr) / 2;
        return min(query(k*2,tl,tm,l,r), query(k*2+1,tm+1,tr,l,r));
    }

    void modify(int p,int v){
        modify(1, 0, n-1,p, v);
    }
    int query(int l,int r){
        return query(1, 0,n-1,l,r);
    }
};

struct Dev{
    ll i,  a,  b,  c,  d;
    ll dp[2] = {INF,  INF};
    bool operator < (const Dev o) const {
        return b < o.b;
    }
};

Dev A[N];

void solve(int T){
    cin>>n>>m;
    set<int> s;
    for(int i = 0;i<n;i++){
        cin>>A[i].a>>A[i].b>>A[i].c>>A[i].d;
        s.insert(A[i].a);
        s.insert(A[i].b);
        s.insert(A[i].c);

        A[i].i = i;
    }
    s.insert(1);
    s.insert(m);
    
    int x = 0;

    map<int,int> mp;
    for(auto u : s)mp[u] = x++;

    for(int i = 0;i<n;i++){
        A[i].a = mp[A[i].a];
        A[i].b = mp[A[i].b];
        A[i].c = mp[A[i].c];

    }
    SGT s1(x), s2(x);

    s1.modify(0, 0);
    s2.modify(x-1,0);
    ans = INF;
    for(int i = 0;i<n;i++){
        A[i].dp[0] = s1.query(A[i].a, A[i].b) + A[i].d;
        s1.modify(A[i].c, A[i].dp[0]);
        A[i].dp[1] = s2.query(A[i].a, A[i].b) + A[i].d;
        s2.modify(A[i].c, A[i].dp[1]);
        ans = min(ans, A[i].dp[0] + A[i].dp[1] - A[i].d);
    }
    if(ans >= INF)ans = -1;
    cout<<ans<<endl;
}
//Te molam da raboti !!
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5724 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 1 ms 5720 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 2 ms 5724 KB Output is correct
7 Correct 1 ms 5724 KB Output is correct
8 Correct 3 ms 5724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5724 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 1 ms 5720 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 2 ms 5724 KB Output is correct
7 Correct 1 ms 5724 KB Output is correct
8 Correct 3 ms 5724 KB Output is correct
9 Correct 2 ms 5724 KB Output is correct
10 Correct 2 ms 5724 KB Output is correct
11 Correct 2 ms 5976 KB Output is correct
12 Correct 2 ms 5980 KB Output is correct
13 Correct 2 ms 5980 KB Output is correct
14 Correct 2 ms 5980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5724 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 1 ms 5720 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 2 ms 5724 KB Output is correct
7 Correct 1 ms 5724 KB Output is correct
8 Correct 3 ms 5724 KB Output is correct
9 Correct 2 ms 5724 KB Output is correct
10 Correct 2 ms 5724 KB Output is correct
11 Correct 2 ms 5976 KB Output is correct
12 Correct 2 ms 5980 KB Output is correct
13 Correct 2 ms 5980 KB Output is correct
14 Correct 2 ms 5980 KB Output is correct
15 Correct 2 ms 5724 KB Output is correct
16 Correct 2 ms 5980 KB Output is correct
17 Correct 3 ms 5980 KB Output is correct
18 Correct 2 ms 5724 KB Output is correct
19 Correct 3 ms 6236 KB Output is correct
20 Correct 3 ms 5980 KB Output is correct
21 Correct 2 ms 6044 KB Output is correct
22 Correct 3 ms 6236 KB Output is correct
23 Correct 5 ms 6236 KB Output is correct
24 Correct 3 ms 6300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5724 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 1 ms 5720 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 2 ms 5724 KB Output is correct
7 Correct 1 ms 5724 KB Output is correct
8 Correct 3 ms 5724 KB Output is correct
9 Correct 2 ms 5724 KB Output is correct
10 Correct 2 ms 5724 KB Output is correct
11 Correct 2 ms 5976 KB Output is correct
12 Correct 2 ms 5980 KB Output is correct
13 Correct 2 ms 5980 KB Output is correct
14 Correct 2 ms 5980 KB Output is correct
15 Correct 2 ms 5724 KB Output is correct
16 Correct 2 ms 5980 KB Output is correct
17 Correct 3 ms 5980 KB Output is correct
18 Correct 2 ms 5724 KB Output is correct
19 Correct 3 ms 6236 KB Output is correct
20 Correct 3 ms 5980 KB Output is correct
21 Correct 2 ms 6044 KB Output is correct
22 Correct 3 ms 6236 KB Output is correct
23 Correct 5 ms 6236 KB Output is correct
24 Correct 3 ms 6300 KB Output is correct
25 Correct 26 ms 8916 KB Output is correct
26 Correct 75 ms 15316 KB Output is correct
27 Correct 188 ms 23424 KB Output is correct
28 Correct 106 ms 5976 KB Output is correct
29 Correct 133 ms 21584 KB Output is correct
30 Correct 170 ms 8788 KB Output is correct
31 Correct 316 ms 34780 KB Output is correct
32 Correct 250 ms 26448 KB Output is correct
33 Incorrect 51 ms 15952 KB Output isn't correct
34 Halted 0 ms 0 KB -