Submission #64291411
Source Code Expand
#include <iostream>
#include <vector>
#include <algorithm>
#include<unordered_map>
#define int long long
using namespace std;
signed main() {
int n; cin>>n;
vector<int> arr(n);
for(int i=0;i<n;i++) cin>>arr[i];
vector<vector<int>> pairs;
vector<int> ans(n);
for(int i=0;i<n;i++) pairs.push_back({arr[i], i});
sort(pairs.rbegin(), pairs.rend());
int rank = 1;
for(int i=0;i<n;i++) {
int num = pairs[i][0], lastIdx = i;
for(int j=i;j<n;j++) {
if(pairs[j][0] == num){
lastIdx = j;
}else break;
}
for(int j=i;j<=lastIdx;j++) ans[pairs[j][1]] = rank;
rank += lastIdx - i + 1;
i = lastIdx;
}
for(int i : ans) cout<<i<<' ';
cout<<endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Ranking with Ties |
| User | sivasaran2003 |
| Language | C++ 20 (gcc 12.2) |
| Score | 200 |
| Code Size | 841 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3704 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 03_sorted_00.txt, 03_sorted_01.txt, 04_handmade_00.txt, 04_handmade_01.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3508 KiB |
| 00_sample_01.txt | AC | 1 ms | 3560 KiB |
| 00_sample_02.txt | AC | 1 ms | 3704 KiB |
| 00_sample_03.txt | AC | 1 ms | 3508 KiB |
| 01_random_00.txt | AC | 1 ms | 3668 KiB |
| 01_random_01.txt | AC | 1 ms | 3444 KiB |
| 01_random_02.txt | AC | 1 ms | 3512 KiB |
| 01_random_03.txt | AC | 1 ms | 3500 KiB |
| 02_random2_00.txt | AC | 1 ms | 3508 KiB |
| 02_random2_01.txt | AC | 1 ms | 3668 KiB |
| 02_random2_02.txt | AC | 1 ms | 3516 KiB |
| 02_random2_03.txt | AC | 1 ms | 3516 KiB |
| 02_random2_04.txt | AC | 1 ms | 3448 KiB |
| 02_random2_05.txt | AC | 1 ms | 3508 KiB |
| 02_random2_06.txt | AC | 1 ms | 3576 KiB |
| 02_random2_07.txt | AC | 1 ms | 3572 KiB |
| 02_random2_08.txt | AC | 1 ms | 3516 KiB |
| 03_sorted_00.txt | AC | 1 ms | 3564 KiB |
| 03_sorted_01.txt | AC | 1 ms | 3620 KiB |
| 04_handmade_00.txt | AC | 1 ms | 3464 KiB |
| 04_handmade_01.txt | AC | 1 ms | 3576 KiB |