Submission #1276041

#TimeUsernameProblemLanguageResultExecution timeMemory
1276041sakkaBubble Sort Machine (JOI25_bubble)C++20
11 / 100
465 ms8656 KiB
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define pll pair<long long, long long>
using namespace std;
void freop(){
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}
const ll MOD = 1e9+7, INF = 1e18;
ll n , Q;
vector<ll> vec(5e5 + 2);

void solve(){
    cin >> n;
    for(int i=1; i<=n; i++) cin >> vec[i];

    ll last = INF;
    vector<ll> ch;
    for(int i=1; i<=n; i++){
        if(vec[i] < last){
            last = vec[i];
            ch.pb(i-1);
        }
    }
    ch.pb(INF);

    // cout << ch.size() << endl;
    // for(ll x : ch) cout << x << " "; cout << endl;

    cin >> Q;
    ll cnt = 0, idx = 0;
    while(Q--){
        int op ; cin >> op;
        if(op == 1) cnt++;
        else{
            ll l, r; cin >> l >> r;
            if(idx >= ch.size()-1){}
            else{
                while(cnt > ch[idx]){
                    if(cnt >= ch[idx+1]) idx++;
                    else break;
                    if(idx >= ch.size()) break;
                }
            }
            
            cout << vec[ch[idx] + 1] << endl;
        }
    }
}

int main(){
    ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freop();
    solve();
}

Compilation message (stderr)

bubble.cpp: In function 'void freop()':
bubble.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bubble.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...