提出 #48926333
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll MOD=998244353;
// head
const int N=2e5+5;
int a[N],b[N];
map<int,int> M;
int sum[N];
signed main()
{
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;cin>>n;
for(int i=0;i<n;i++) {cin>>a[i];b[i]=a[i];}
sort(b,b+n);
reverse(b,b+n);
int last=0,cnt=1;
for(int i=1;i<n;i++){
if(b[i]!=b[i-1]){
M[b[i-1]]=last;
last++;
}
}
M[b[n-1]]=last;
for(int i=0;i<n;i++){
sum[M[a[i]]]++;
}
for(int i=0;i<n;i++){
cout<<sum[i]<<endl;
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - (K+1)-th Largest Number |
| ユーザ | gangbengr |
| 言語 | C++ 20 (gcc 12.2) |
| 得点 | 300 |
| コード長 | 793 Byte |
| 結果 | AC |
| 実行時間 | 335 ms |
| メモリ | 20664 KiB |
コンパイルエラー
Main.cpp: In function ‘int main()’:
Main.cpp:28:20: warning: unused variable ‘cnt’ [-Wunused-variable]
28 | int last=0,cnt=1;
| ^~~
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, example0.txt, example1.txt, example2.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 000.txt | AC | 191 ms | 6600 KiB |
| 001.txt | AC | 333 ms | 20604 KiB |
| 002.txt | AC | 251 ms | 13584 KiB |
| 003.txt | AC | 163 ms | 12668 KiB |
| 004.txt | AC | 117 ms | 10256 KiB |
| 005.txt | AC | 62 ms | 7112 KiB |
| 006.txt | AC | 331 ms | 20592 KiB |
| 007.txt | AC | 335 ms | 20560 KiB |
| 008.txt | AC | 329 ms | 20664 KiB |
| 009.txt | AC | 194 ms | 6712 KiB |
| 010.txt | AC | 195 ms | 6728 KiB |
| 011.txt | AC | 196 ms | 6572 KiB |
| 012.txt | AC | 196 ms | 6548 KiB |
| 013.txt | AC | 196 ms | 6628 KiB |
| 014.txt | AC | 324 ms | 19648 KiB |
| 015.txt | AC | 239 ms | 8216 KiB |
| 016.txt | AC | 216 ms | 6832 KiB |
| 017.txt | AC | 199 ms | 6620 KiB |
| 018.txt | AC | 208 ms | 6692 KiB |
| 019.txt | AC | 210 ms | 6672 KiB |
| 020.txt | AC | 205 ms | 6700 KiB |
| 021.txt | AC | 203 ms | 6628 KiB |
| 022.txt | AC | 203 ms | 6604 KiB |
| 023.txt | AC | 205 ms | 6608 KiB |
| example0.txt | AC | 1 ms | 3376 KiB |
| example1.txt | AC | 1 ms | 3436 KiB |
| example2.txt | AC | 1 ms | 3420 KiB |