답안 #898089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
898089 2024-01-04T09:51:46 Z vjudge1 Passport (JOI23_passport) C++17
0 / 100
0 ms 348 KB
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define str string
#define int long long
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define all(x) x.begin() , x.end()
#define setpr(x) cout << fixed << setprecision(x) 
#define endl '\n'
 
const int inf = INT_MAX;
const ld eps = 1e-9 , pi = acos(-1.0);
const ll mod = 1e9 + 7; // 998244353;
const int dx[4]{1 , 0 , -1 , 0} , dy[4]{0 , 1 , 0 , -1};

/*
    T_ai <= T_bi --> 
    ai < bi --> S_(ai + 1 , bi) <= S_(ai , bi - 1)
    ai > bi --> S_(bi + 1 , ai) >= S_(bi , ai - 1)
*/

void solution(){
    int n , x; cin >> n;
    vector<pair<int , int>> bu(n);
    for(int i = 0 ; i < n ; i ++) cin >> bu[i].F >> bu[i].S;
    int q; cin >> q;
    while(q --) cin >> x;
    int l = bu[x - 1].F , r = -1 , h = 0;
    multiset<int> st; st.insert(bu[x - 1].S);
    for(int i = 0 ; i < n ; i ++){
        r = *st.rbegin();
        if(r != -1) l = r;
        for(int i = l ; i <= r ; i ++) st.insert(bu[i].S);
        h ++;
        if(r == n) break;
    }
    cout << h << endl;
}  
 
signed main(){
    IOS;
    int t = 1; // cin >> t;
    while(t --) solution();
}   
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -