360笔试,运动员第二题,80%,到底哪里错了,请教大佬们
哇,改了半天,也不知道哪里出错了,一直80%
贴下代码,希望能有人帮忙指出来,感激不尽
#include <iostream> #include <vector> #include <set> using namespace std; int n; vector<int> athl, savevec; multiset<int> spers; void Init() { athl.clear(); savevec.clear(); spers.clear(); cin >> n; int t, i(n); while (i--) { cin >> t; athl.push_back(t); } return; } int FindK(multiset<int> &s, int x) { s.insert(x); int cnt(0); for (auto it = s.begin(); it != s.end(); it++) { cnt++; if (*it == x) { auto tmp = it; ++tmp; if (tmp != s.end() && *tmp == x) continue; return s.size()-cnt; } } } void Figure() { int cnt; for (int i = 0; i < n; i++) { cnt = FindK(spers, athl[i]); savevec.push_back(cnt); } for (int i = 0; i < savevec.size()-1; i++) cout << savevec[i] << " "; cout << savevec[savevec.size()-1] << endl; } int main() { Init(); Figure(); return 0; }