P7910 76pts (TLE)

This commit is contained in:
2024-10-10 21:15:37 +08:00
parent 783cd3980a
commit 64e55d4c4b
4 changed files with 52 additions and 8 deletions

6
insert-sort/data.in Normal file
View File

@ -0,0 +1,6 @@
3 4
3 2 1
2 3
1 3 2
2 2
2 3

38
insert-sort/main.cc Normal file
View File

@ -0,0 +1,38 @@
// The question want me to impl a sort by my self
// But absolutely not
#include <iostream>
using namespace std;
int main() {
int n, Q;
cin >> n >> Q;
int arr[n + 5];
for (int i = 1; i <= n; i++) {
cin >> arr[i];
}
for (int i = 0; i < Q; i++) {
int op;
cin >> op;
if (op == 1) {
int x, v;
cin >> x >> v;
arr[x] = v;
} else {
int xn;
cin >> xn;
int it = arr[xn];
int pos = n;
for (int j = 1; j < xn; j++) {
if (arr[j] > it) pos--;
}
for (int j = xn + 1; j <= n; j++) {
if (arr[j] >= it) pos--;
}
cout << pos << endl;
}
}
}