Submission #64286708
Source Code Expand
#include <bits/stdc++.h>
#define _F(x,y,z) for(int x=y;x<=z;x++)
#define F_(x,z,y) for(int x=z;x>=y;x--)
#define TF(x,y,z) for(int x=head[y],z;x;x=nex[x])
using namespace std;
typedef long long ll;
typedef double dou;
typedef const int ci;
typedef pair<int,int> pii;
ci maxn=2e6+10;
int n,ans[maxn],id[maxn],a[maxn],cnt,k;
int main()
{
scanf("%d",&n);
_F(i,1,n)
{
scanf("%d",&a[i]);id[i]=i;
}
sort(id+1,id+1+n,[](int x,int y){
return a[x]>a[y];
});
_F(i,1,n)
{
k=i;
while(a[id[k]]==a[id[k+1]])
ans[id[k]]=i,k++;
ans[id[k]]=i;i=k;
}
_F(i,1,n)
{
printf("%d\n",ans[i]);
}
return 0;
}
Submission Info
| Submission Time |
|
| Task |
B - Ranking with Ties |
| User |
adolphshi |
| Language |
C++ 20 (gcc 12.2) |
| Score |
200 |
| Code Size |
650 Byte |
| Status |
AC |
| Exec Time |
2 ms |
| Memory |
3884 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
Main.cpp:21:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d",&a[i]);id[i]=i;
| ~~~~~^~~~~~~~~~~~
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 |
3760 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3756 KiB |
| 00_sample_02.txt |
AC |
2 ms |
3884 KiB |
| 00_sample_03.txt |
AC |
1 ms |
3820 KiB |
| 01_random_00.txt |
AC |
1 ms |
3628 KiB |
| 01_random_01.txt |
AC |
1 ms |
3696 KiB |
| 01_random_02.txt |
AC |
1 ms |
3816 KiB |
| 01_random_03.txt |
AC |
1 ms |
3644 KiB |
| 02_random2_00.txt |
AC |
1 ms |
3632 KiB |
| 02_random2_01.txt |
AC |
1 ms |
3684 KiB |
| 02_random2_02.txt |
AC |
1 ms |
3756 KiB |
| 02_random2_03.txt |
AC |
1 ms |
3884 KiB |
| 02_random2_04.txt |
AC |
1 ms |
3760 KiB |
| 02_random2_05.txt |
AC |
1 ms |
3688 KiB |
| 02_random2_06.txt |
AC |
1 ms |
3644 KiB |
| 02_random2_07.txt |
AC |
1 ms |
3688 KiB |
| 02_random2_08.txt |
AC |
2 ms |
3692 KiB |
| 03_sorted_00.txt |
AC |
1 ms |
3692 KiB |
| 03_sorted_01.txt |
AC |
1 ms |
3660 KiB |
| 04_handmade_00.txt |
AC |
2 ms |
3824 KiB |
| 04_handmade_01.txt |
AC |
1 ms |
3696 KiB |