提出 #48118806


ソースコード 拡げる

#include <bits/stdc++.h>
#include <atcoder/modint>

namespace {
using ModInt [[maybe_unused]] = atcoder::modint998244353;
using Num [[maybe_unused]] = long long int;
using Vec [[maybe_unused]] = std::vector<Num>;
using Set [[maybe_unused]] = std::set<Num>;
using Mset [[maybe_unused]] = std::multiset<Num>;
using Edges [[maybe_unused]] = std::vector<std::vector<Num>>;

template<typename T>
using Q [[maybe_unused]] = std::queue<T>;

template<typename T>
using PQ [[maybe_unused]] = std::priority_queue<T, std::vector<T>, std::greater<T>>;
}

void solve(std::istream& is, std::ostream& os) {
    Num n {0};
    is >> n;

    Vec aset(n);
    for(auto&& x : aset) {
        is >> x;
    }

    auto ss = aset;
    std::ranges::sort(ss);
    Vec cumsum {0};
    for(const auto& x : ss) {
        cumsum.push_back(cumsum.back() + x);
    }

    const Num sum = cumsum.back();

    for(Num i{0}; i<n; ++i) {
        const auto a = aset.at(i);
        auto d = std::upper_bound(ss.begin(), ss.end(), a) - ss.begin();
        auto ans = sum - cumsum.at(d);
        os << ans;
        if ((i + 1) == n) {
            os << "\n";
        } else {
            os << " ";
        }
    }
}

int main(void) {
    solve(std::cin, std::cout);
    return 0;
}

提出情報

提出日時
問題 C - Sum of Numbers Greater Than Me
ユーザ zettsut
言語 C++ 20 (gcc 12.2)
得点 300
コード長 1299 Byte
結果 AC
実行時間 94 ms
メモリ 8384 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 21
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 1 ms 3464 KiB
random_01.txt AC 90 ms 8248 KiB
random_02.txt AC 56 ms 6176 KiB
random_03.txt AC 91 ms 8268 KiB
random_04.txt AC 90 ms 8268 KiB
random_05.txt AC 94 ms 8296 KiB
random_06.txt AC 13 ms 4088 KiB
random_07.txt AC 93 ms 8292 KiB
random_08.txt AC 78 ms 7972 KiB
random_09.txt AC 90 ms 8352 KiB
random_10.txt AC 11 ms 3844 KiB
random_11.txt AC 34 ms 8260 KiB
random_12.txt AC 57 ms 8268 KiB
random_13.txt AC 57 ms 8348 KiB
random_14.txt AC 94 ms 8232 KiB
random_15.txt AC 92 ms 8384 KiB
random_16.txt AC 71 ms 8352 KiB
random_17.txt AC 70 ms 8332 KiB
sample_01.txt AC 1 ms 3532 KiB
sample_02.txt AC 1 ms 3512 KiB
sample_03.txt AC 1 ms 3548 KiB