Submission #106231

#TimeUsernameProblemLanguageResultExecution timeMemory
106231abilExamination (JOI19_examination)C++14
0 / 100
3033 ms13332 KiB
#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 (stderr)

examination.cpp:40:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...