网易0327笔试算法岗第一题
第一题只过了50% 有大佬帮忙看看哪里有问题吗
#include<iostream> #include<math.h> #include<string> #include<vector> #include<algorithm> #include<unordered_map> #include<map> #include<numeric> using namespace std; int a[200001]; int main() { int n; cin >> n; string s; for (int i = 0; i < n; i++) { cin >> a[i]; } cin >> s; //询问次数 int times; cin >> times; // for (int i = 0; i < times; i++) { //第x天的得分 //红色 小红得分 紫色 小紫得分 int x; cin >> x; //数组长度为n int start = 0; int rScores = 0; int pScores = 0; int index = 0; while (x) { //当前所在的位置 if (start >= n) { start = 0; } index = start; //小红得分 if (s[index] == 'R') { rScores += a[index]; } //小紫得分 else { pScores += a[index]; } start++; x--; } cout << rScores << " " << pScores << endl; } }