#include "bubblesort2.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n;
int a[500005];
int aib[500005];
int calcmax()
{
ordered_set s;
int mxm=0;
for(int i=0;i<n;i++)
{
s.insert({a[i],i});
int cv = s.order_of_key({a[i],i});
mxm = max(mxm, i-cv);
}
return mxm;
}
std::vector<int> countScans(std::vector<int> A, std::vector<int> qp, std::vector<int> qv){
int q=qp.size();
n=A.size();
for(int i=0;i<n;i++)
a[i]=A[i];
std::vector<int> answer(q);
for (int i=0;i<q;i++)
{
a[qp[i]] = qv[i];
answer[i] = calcmax();
}
return answer;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
2396 KB |
Output is correct |
2 |
Correct |
124 ms |
2548 KB |
Output is correct |
3 |
Correct |
782 ms |
2652 KB |
Output is correct |
4 |
Correct |
779 ms |
2904 KB |
Output is correct |
5 |
Correct |
765 ms |
2656 KB |
Output is correct |
6 |
Correct |
741 ms |
2900 KB |
Output is correct |
7 |
Correct |
771 ms |
2652 KB |
Output is correct |
8 |
Correct |
783 ms |
2904 KB |
Output is correct |
9 |
Correct |
764 ms |
2652 KB |
Output is correct |
10 |
Correct |
680 ms |
2652 KB |
Output is correct |
11 |
Correct |
684 ms |
2648 KB |
Output is correct |
12 |
Correct |
661 ms |
2656 KB |
Output is correct |
13 |
Correct |
658 ms |
2648 KB |
Output is correct |
14 |
Correct |
672 ms |
2652 KB |
Output is correct |
15 |
Correct |
651 ms |
2656 KB |
Output is correct |
16 |
Correct |
650 ms |
2652 KB |
Output is correct |
17 |
Correct |
665 ms |
2896 KB |
Output is correct |
18 |
Correct |
722 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
2396 KB |
Output is correct |
2 |
Correct |
124 ms |
2548 KB |
Output is correct |
3 |
Correct |
782 ms |
2652 KB |
Output is correct |
4 |
Correct |
779 ms |
2904 KB |
Output is correct |
5 |
Correct |
765 ms |
2656 KB |
Output is correct |
6 |
Correct |
741 ms |
2900 KB |
Output is correct |
7 |
Correct |
771 ms |
2652 KB |
Output is correct |
8 |
Correct |
783 ms |
2904 KB |
Output is correct |
9 |
Correct |
764 ms |
2652 KB |
Output is correct |
10 |
Correct |
680 ms |
2652 KB |
Output is correct |
11 |
Correct |
684 ms |
2648 KB |
Output is correct |
12 |
Correct |
661 ms |
2656 KB |
Output is correct |
13 |
Correct |
658 ms |
2648 KB |
Output is correct |
14 |
Correct |
672 ms |
2652 KB |
Output is correct |
15 |
Correct |
651 ms |
2656 KB |
Output is correct |
16 |
Correct |
650 ms |
2652 KB |
Output is correct |
17 |
Correct |
665 ms |
2896 KB |
Output is correct |
18 |
Correct |
722 ms |
2652 KB |
Output is correct |
19 |
Execution timed out |
9030 ms |
2908 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
9038 ms |
4444 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
2396 KB |
Output is correct |
2 |
Correct |
124 ms |
2548 KB |
Output is correct |
3 |
Correct |
782 ms |
2652 KB |
Output is correct |
4 |
Correct |
779 ms |
2904 KB |
Output is correct |
5 |
Correct |
765 ms |
2656 KB |
Output is correct |
6 |
Correct |
741 ms |
2900 KB |
Output is correct |
7 |
Correct |
771 ms |
2652 KB |
Output is correct |
8 |
Correct |
783 ms |
2904 KB |
Output is correct |
9 |
Correct |
764 ms |
2652 KB |
Output is correct |
10 |
Correct |
680 ms |
2652 KB |
Output is correct |
11 |
Correct |
684 ms |
2648 KB |
Output is correct |
12 |
Correct |
661 ms |
2656 KB |
Output is correct |
13 |
Correct |
658 ms |
2648 KB |
Output is correct |
14 |
Correct |
672 ms |
2652 KB |
Output is correct |
15 |
Correct |
651 ms |
2656 KB |
Output is correct |
16 |
Correct |
650 ms |
2652 KB |
Output is correct |
17 |
Correct |
665 ms |
2896 KB |
Output is correct |
18 |
Correct |
722 ms |
2652 KB |
Output is correct |
19 |
Execution timed out |
9030 ms |
2908 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |