#include "bits/stdc++.h"
using namespace std;
#define INF 2000000000
#define INFLL 3000000000000000000LL
#define ll long long
int main() {
cin.tie(0)->sync_with_stdio(0);
int n,q;
cin>>n>>q;
pair<pair<int,int>,int>arr[n];
for(int i=0;i<n;i++){
int l,r;
cin>>l>>r;
arr[i]={{l,r},i+1};
}
sort(arr,arr+n);
map<int,int>mp;
for(int i=0;i<n;i++){
mp[arr[i].second]=i;
}
cout<<"\n";
while(q--){
int a,b;
cin>>a>>b;
int out=mp[b]-mp[a];
if(out<0)cout<<"impossible\n";
else cout<<out<<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
7684 KB |
Output is correct |
2 |
Correct |
117 ms |
9808 KB |
Output is correct |
3 |
Correct |
154 ms |
9768 KB |
Output is correct |
4 |
Incorrect |
110 ms |
9796 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |