#include <iostream>
#include <algorithm>
using namespace std;
typedef pair < int, int > PII;
typedef pair < int, PII > Type;
const int NMAX = 2e5 + 1, QMAX = 2e5 + 1;
int N, Q, A[NMAX];
Type Queries[QMAX];
int B[(NMAX + QMAX)], V[(NMAX + QMAX)];
static inline void Read ()
{
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> Q;
for(int i = 1; i <= N; ++i)
cin >> A[i], V[++V[0]] = A[i];
for(int i = 1; i <= Q; ++i)
{
cin >> Queries[i].first >> Queries[i].second.first;
if(Queries[i].first == 2)
cin >> Queries[i].second.second, V[++V[0]] = Queries[i].second.second;
else
V[++V[0]] = Queries[i].second.first;
}
return;
}
static inline void Normalize ()
{
sort(V + 1, V + V[0] + 1);
B[++B[0]] = V[1];
for(int i = 2; i <= N; ++i)
if(V[i] != V[i - 1])
B[++B[0]] = V[i];
return;
}
static inline void Solve ()
{
for(int i = 1; i <= Q; ++i)
if(Queries[i].first == 1)
{
int ans = 0;
for(int j = 1; j <= N; ++j)
if(A[j] >= Queries[i].second.first && A[j - 1] < Queries[i].second.first)
++ans;
cout << ans << '\n';
}
else
A[Queries[i].second.first] = Queries[i].second.second;
return;
}
int main()
{
Read();
Normalize();
Solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
400 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
9 ms |
512 KB |
Output is correct |
11 |
Correct |
10 ms |
512 KB |
Output is correct |
12 |
Correct |
9 ms |
512 KB |
Output is correct |
13 |
Correct |
9 ms |
512 KB |
Output is correct |
14 |
Correct |
12 ms |
512 KB |
Output is correct |
15 |
Correct |
9 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
504 KB |
Output is correct |
2 |
Correct |
38 ms |
512 KB |
Output is correct |
3 |
Correct |
23 ms |
512 KB |
Output is correct |
4 |
Correct |
1050 ms |
1316 KB |
Output is correct |
5 |
Correct |
4369 ms |
1976 KB |
Output is correct |
6 |
Execution timed out |
5023 ms |
2976 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
400 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
9 ms |
512 KB |
Output is correct |
11 |
Correct |
10 ms |
512 KB |
Output is correct |
12 |
Correct |
9 ms |
512 KB |
Output is correct |
13 |
Correct |
9 ms |
512 KB |
Output is correct |
14 |
Correct |
12 ms |
512 KB |
Output is correct |
15 |
Correct |
9 ms |
512 KB |
Output is correct |
16 |
Correct |
29 ms |
504 KB |
Output is correct |
17 |
Correct |
38 ms |
512 KB |
Output is correct |
18 |
Correct |
23 ms |
512 KB |
Output is correct |
19 |
Correct |
1050 ms |
1316 KB |
Output is correct |
20 |
Correct |
4369 ms |
1976 KB |
Output is correct |
21 |
Execution timed out |
5023 ms |
2976 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |