提出 #64298697


ソースコード 拡げる

#include <bits/stdc++.h>
using ll = long long;

const int N = 3e5;

void solve() {
    int n;
    std::cin >> n;
    std::vector<int> a(n, 0), b(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        b[i] = a[i];
    }
    std::sort(b.begin(), b.end());
    std::map<int, int> mp;
    int r = 1, x = b[n - 1], cnt = 0;;
    int k = 1;
    for (int i = n - 1; i >= 0; i--) {
        if (b[i] == x) {
            cnt++;
            mp[b[i]] = r;
        } else {
            x = b[i];
            r += cnt;
            cnt = 1;
            mp[b[i]] = r;
        }

    }
    for (int i = 0; i < n; i++) {
        std::cout << mp[a[i]] << "\n";
    }
}

int main() {
    std::ios::sync_with_stdio(false), std::cout.tie(nullptr), std::cin.tie(nullptr);
    int t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

提出情報

提出日時
問題 B - Ranking with Ties
ユーザ mellowsky
言語 C++ 20 (gcc 12.2)
得点 200
コード長 889 Byte
結果 AC
実行時間 1 ms
メモリ 3568 KiB

コンパイルエラー

Main.cpp: In function ‘void solve()’:
Main.cpp:17:9: warning: unused variable ‘k’ [-Wunused-variable]
   17 |     int k = 1;
      |         ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 4
AC × 21
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3480 KiB
00_sample_01.txt AC 1 ms 3496 KiB
00_sample_02.txt AC 1 ms 3472 KiB
00_sample_03.txt AC 1 ms 3424 KiB
01_random_00.txt AC 1 ms 3352 KiB
01_random_01.txt AC 1 ms 3564 KiB
01_random_02.txt AC 1 ms 3488 KiB
01_random_03.txt AC 1 ms 3492 KiB
02_random2_00.txt AC 1 ms 3356 KiB
02_random2_01.txt AC 1 ms 3568 KiB
02_random2_02.txt AC 1 ms 3564 KiB
02_random2_03.txt AC 1 ms 3440 KiB
02_random2_04.txt AC 1 ms 3440 KiB
02_random2_05.txt AC 1 ms 3412 KiB
02_random2_06.txt AC 1 ms 3528 KiB
02_random2_07.txt AC 1 ms 3496 KiB
02_random2_08.txt AC 1 ms 3568 KiB
03_sorted_00.txt AC 1 ms 3432 KiB
03_sorted_01.txt AC 1 ms 3568 KiB
04_handmade_00.txt AC 1 ms 3496 KiB
04_handmade_01.txt AC 1 ms 3484 KiB