이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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){
return x.fr.fr < y.fr.fr;
}
bool cmp1(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
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();
}
}
컴파일 시 표준 에러 (stderr) 메시지
examination.cpp:30:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |