답안 #1120130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1120130 2024-11-28T05:16:17 Z vjudge1 Event Hopping (BOI22_events) C++17
0 / 100
86 ms 12776 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
void solve() {
    ll n; cin>>n;
    ll Q; cin>>Q;
    map<ll, ll> ord;
    vector<pair<ll, pair<ll, ll>>> v;
    for(ll i=1; i<=n; i++) {
        ll l,r; cin>>l>>r;
        v.push_back({r, {l, i}});
    }
    sort(v.begin(), v.end());
    ll p=1;
    ll lst=-1;
    for(auto [r, to]: v) {
        ll l=to.f, i=to.s;
        if(lst == -1 || (l <= lst && lst <= r)) {
            ord[p++]=i;
            lst=r;
        }
    }
    for(ll i=1; i<=Q; i++) {
        ll l, r; cin>>l>>r;
        if(ord[r]-ord[l] <= 0) cout<<"impossible\n";
        else cout<<ord[r]-ord[l]<<"\n";
    }
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--) {
        solve();
        cout<<'\n';
    }
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 12776 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -