Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <vector>
- #include <algorithm>
- #define endl '\n'
- using namespace std;
- int main(){
- int n,m;
- while(~scanf("%d %d", &n, &m) && (n || m) ){
- vector<int> arr;
- for(int i=0;i<n;i++){
- int tmp;
- scanf("%d",&tmp);
- arr.push_back(tmp);
- }
- sort(arr.begin(),arr.end());
- while(m--){
- int l,u;
- scanf("%d %d", &l, &u);
- cout << upper_bound(arr.begin(), arr.end(), u) - lower_bound(arr.begin(), arr.end(), l) << endl;
- }
- }
- return 0;
- }
- /**************************************************************
- Problem: 1012
- User: 410621221
- Language: C++
- Result: 正确
- Time:4192 ms
- Memory:8260 kb
- ****************************************************************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement