Submission #106231

# Submission time Handle Problem Language Result Execution time Memory
106231 2019-04-17T13:56:40 Z abil Examination (JOI19_examination) C++14
0 / 100
3000 ms 13332 KB
#include <bits/stdc++.h>
#define int long long
#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)

using namespace std;

const long long INF = (int)1e18 + 7;
const int N = (int)3e5 + 7;
const int mod = 1000000007;

int n, q, s[N], t[N];
vector<pair<pair<int,int >,int >> v,w;

bool cmp(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
      if(x.fr.fr == y.fr.fr){
            return x.fr.sc < y.fr.sc;
      }
      else{
            return x.fr.fr < y.fr.fr;
      }
}
bool cmp1(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
      if(x.fr.sc == y.fr.sc){
            return x.sc < y.sc;
      }
      else{
            return x.fr.sc < y.fr.sc;
      }
}
bool cmp2(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
            return x.sc <= y.sc;
}
main(){
      cin >> n >> q;
      for(int i = 1;i <= n; i++){
            cin >> s[i] >> t[i];
            v.pb(mk(mk(s[i] + t[i],s[i]),t[i]));
      }
      sort(all(v),cmp);
      int a, b, c;
      while(q--){
            cin >> a >> b >> c;
            w = v;
            int l = 0, r = n - 1;
            while(r - l > 1){
                  int mid = (r + l) >> 1;
                  if(w[mid].fr.fr >= c){
                        r = mid;
                  }
                  else{
                        l = mid;
                  }
            }
            if(w[l].fr.fr >= c){
                   r = l;
            }
            sort(w.begin() + r,w.end(),cmp1);
            l = r, r = n - 1;
            while(r - l > 1){
                  int mid = (r + l) >> 1;
                  if(w[mid].fr.sc >= a){
                        r = mid;
                  }
                  else{
                        l = mid;
                  }
            }
            if(w[l].fr.sc >= a){
                   r = l;
            }
            sort(w.begin() + r,w.end(),cmp2);
            l = r, r = n - 1;
            while(r - l > 1){
                  int mid = (r + l) >> 1;
                  if(w[mid].sc >= b){
                        r = mid;
                  }
                  else{
                        l = mid;
                  }
            }
            if(w[l].sc >= b){
                   r = l;
            }
            cout << max(n - r,0ll) << endl;
            w.clear();
      }
}

Compilation message

examination.cpp:40:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3033 ms 13332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3033 ms 13332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -