Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
324130 刘铄 【C6-8】小X算排名 C++ 编译错误 0 0 MS 0 KB 829 2025-05-24 16:41:45

Tests(0/0):


#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int> scores(N), sorted_scores(N); for(int i = 0; i < N; ++i) { cin >> scores[i]; sorted_scores[i] = scores[i]; } sort(sorted_scores.begin(), sorted_scores.end(), greater<int>()); vector<int> ranks(N); ranks[0] = 1; for(int i = 1; i < N; ++i) { if(sorted_scores[i] == sorted_scores[i-1]) { ranks[i] = ranks[i-1]; } else { ranks[i] = i + 1; } for(int score : scores) { auto it = lower_bound(sorted_scores.begin(), sorted_scores.end(),score, greater<int>()); int pos = it - sorted_scores.begin(); cout << ranks[pos] << "\n"; } return 0; }


测评信息: