| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1306298 | dex111222333444555 | Matryoshka (JOI16_matryoshka) | C++20 | 2 ms | 2632 KiB |
#include <bits/stdc++.h>
#define all(v) begin(v), end(v)
#define ii pair<int, int>
#define fi first
#define se second
using namespace std;
const int MAXN = 2e5 + 5;
struct Q{
int low, high, id;
Q(int _low = 0, int _high = 0, int _id = 0):
low(_low), high(_high), id(_id) {};
bool operator<(const Q &other){
return low > other.low;
}
};
int numVal, numQuery, res[MAXN];
ii val[MAXN];
Q query[MAXN];
void input(){
cin >> numVal >> numQuery;
for(int i = 1; i <= numVal; i++) cin >> val[i].fi >> val[i].se;
for(int q = 1; q <= numQuery; q++) cin >> query[q].low >> query[q].high, query[q].id = q;
}
bool cmp(const ii &a, const ii &b){
return (a.fi > b.fi) || (a.fi == b.fi && a.se < b.se);
}
void solve(){
vector<int> lis;
sort(val + 1, val + 1 + numVal, greater<ii>());
sort(query + 1, query + 1 + numQuery);
int j = 1;
for(int i = 1; i <= numQuery; i++){
while(j <= numVal && val[j].fi >= query[i].low){
vector<int>::iterator it = upper_bound(all(lis), val[j].se);
if (it == end(lis)) lis.push_back(val[j].se);
else *it = val[j].se;
j++;
}
res[query[i].id] = upper_bound(all(lis), query[i].high) - begin(lis);
}
for(int q = 1; q <= numQuery; q++) cout << res[q] << '\n';
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define task "test"
if (fopen(task".inp", "r")){
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
input();
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
