# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1010656 |
2024-06-29T09:12:07 Z |
pcc |
None (JOI16_matryoshka) |
C++17 |
|
1786 ms |
22060 KB |
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fs first
#define sc second
const int mxn = 4e5+10;
int N,Q;
pii arr[mxn];
int ans[mxn];
pii req[mxn];
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>Q;
for(int i = 1;i<=N;i++)cin>>arr[i].fs>>arr[i].sc;
for(int i = 1;i<=Q;i++)cin>>req[i].fs>>req[i].sc,arr[i+N] = pii(-i,req[i].sc);
sort(arr+1,arr+N+Q+1,[](pii a,pii b){return a.sc == b.sc?a.fs>b.fs:a.sc<b.sc;});
vector<int> lis;
for(int i = 1;i<=N+Q;i++){
cerr<<arr[i].fs<<','<<arr[i].sc<<endl;
if(arr[i].fs<0){
int id = -arr[i].fs;
int lim = -req[id].fs;
auto p = upper_bound(lis.begin(),lis.end(),lim)-lis.begin();
ans[id] = p;
}
else{
int val = -arr[i].fs;
auto p = upper_bound(lis.begin(),lis.end(),val)-lis.begin();
if(p == lis.size())lis.push_back(val);
else lis[p] = val;
}
}
for(int i = 1;i<=Q;i++){
cout<<ans[i]<<'\n';
}
return 0;
}
Compilation message
matryoshka.cpp: In function 'int main()':
matryoshka.cpp:32:9: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | if(p == lis.size())lis.push_back(val);
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
412 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
412 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
352 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
412 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
352 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
9 ms |
556 KB |
Output is correct |
23 |
Correct |
17 ms |
604 KB |
Output is correct |
24 |
Correct |
17 ms |
644 KB |
Output is correct |
25 |
Correct |
17 ms |
560 KB |
Output is correct |
26 |
Correct |
17 ms |
604 KB |
Output is correct |
27 |
Correct |
17 ms |
604 KB |
Output is correct |
28 |
Correct |
17 ms |
600 KB |
Output is correct |
29 |
Correct |
17 ms |
588 KB |
Output is correct |
30 |
Correct |
22 ms |
572 KB |
Output is correct |
31 |
Correct |
17 ms |
604 KB |
Output is correct |
32 |
Correct |
17 ms |
656 KB |
Output is correct |
33 |
Correct |
17 ms |
600 KB |
Output is correct |
34 |
Correct |
17 ms |
600 KB |
Output is correct |
35 |
Correct |
17 ms |
636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
412 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
352 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
9 ms |
556 KB |
Output is correct |
23 |
Correct |
17 ms |
604 KB |
Output is correct |
24 |
Correct |
17 ms |
644 KB |
Output is correct |
25 |
Correct |
17 ms |
560 KB |
Output is correct |
26 |
Correct |
17 ms |
604 KB |
Output is correct |
27 |
Correct |
17 ms |
604 KB |
Output is correct |
28 |
Correct |
17 ms |
600 KB |
Output is correct |
29 |
Correct |
17 ms |
588 KB |
Output is correct |
30 |
Correct |
22 ms |
572 KB |
Output is correct |
31 |
Correct |
17 ms |
604 KB |
Output is correct |
32 |
Correct |
17 ms |
656 KB |
Output is correct |
33 |
Correct |
17 ms |
600 KB |
Output is correct |
34 |
Correct |
17 ms |
600 KB |
Output is correct |
35 |
Correct |
17 ms |
636 KB |
Output is correct |
36 |
Correct |
1774 ms |
17140 KB |
Output is correct |
37 |
Correct |
1664 ms |
15352 KB |
Output is correct |
38 |
Correct |
624 ms |
6996 KB |
Output is correct |
39 |
Correct |
1609 ms |
13184 KB |
Output is correct |
40 |
Correct |
1786 ms |
14120 KB |
Output is correct |
41 |
Correct |
1711 ms |
15576 KB |
Output is correct |
42 |
Correct |
1674 ms |
11664 KB |
Output is correct |
43 |
Correct |
1675 ms |
12344 KB |
Output is correct |
44 |
Correct |
1656 ms |
21704 KB |
Output is correct |
45 |
Correct |
1629 ms |
21868 KB |
Output is correct |
46 |
Correct |
1645 ms |
21844 KB |
Output is correct |
47 |
Correct |
1554 ms |
21456 KB |
Output is correct |
48 |
Correct |
1628 ms |
22060 KB |
Output is correct |
49 |
Correct |
1606 ms |
21504 KB |
Output is correct |
50 |
Correct |
1725 ms |
21996 KB |
Output is correct |