#include <iostream>
#include <vector>
#ifdef _DEBUG
#include <string>
std::string str;
#endif
using namespace std;
int main() {
int n, Q, a, b, c;
cin >> n >> Q;
vector<int> V;
V.push_back(0);
for (int i = 1; i <= n; i++) {
cin >> a;
V.push_back(a);
}
for (int i = 1; i <= Q; i++) {
cin >> a;
if (a == 1) {
cin >> b >> c;
V[b] = c;
}
if (a == 2) {
cin >> b;
int t=1;
for (int j = 1; j < n; j++) {
if (j == b) {
continue;
}
if ((V[j] > V[b])) {
t++;
}
if ((V[j] == V[b]) && (j < b)) {
t++;
}
}
#ifdef _DEBUG
str += to_string(t) + "\n";
#else
cout << t << endl;
#endif
}
}
#ifdef _DEBUG
system("cls");
cout << str;
system("pause");
#endif
}
你问为什么有_DEBUG?我用的是VS2022
我草草的看了一下题目描述,应该是稳定排序,从大到小的排序
我的想法是统计V[j]比V[b]大的数量和V[j]与V[b]相等但j<b的数量
然后死活调不对