爱奇艺第一题Python和C++解答
python版本只有9%Pass,而c++直接AC,大家围观一下???
N, M, P = tuple(map(int, input().split(" ")))
Ai = list(map(int, input().split(" ")))
for _ in range(M):
t = input().split(" ")
if t[0] == "A":
Ai[int(t[1]) - 1] += 1
else:
Ai[int(t[1]) - 1] -= 1
res = 1
for i in range(len(Ai)):
if Ai[i] > Ai[P-1]:
res += 1
print(res)
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n,m,p;
cin >> n >> m >> p;
vector<int> A(n);
for(int i = 0; i < n; i++) {
cin >> A[i];
}
char tmp_ch;
int tmp_i;
for(int i = 0; i < m; i++) {
cin >> tmp_ch >> tmp_i;
if (tmp_ch == 'A') A[tmp_i - 1]++;
else A[tmp_i - 1]--;
}
int res = 1;
for(int i = 0; i < n; i++) {
if (A[i] > A[p - 1]) res++;
}
cout << res;
return 0;
}
#爱奇艺##Python#