結果

問題 No.3656 Game Scores and Costs
コンテスト
ユーザー Te
提出日時 2026-08-30 16:15:57
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 686 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,364 ms
コンパイル使用メモリ 359,688 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-08-30 16:16:07
合計ジャッジ時間 6,355 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other TLE * 1 -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n, k, x, sum, tmp = 0;
    cin >> n;
    cin >> k;
    cin >> x;
    vector<int> a(n);
    for (auto &nx : a)
    {
        cin >> nx;
    };
    sum = 0;
    for (int i = 0; i < n; i++)
    {
        vector<int> b(i + 1);
        for (int j = 0; j <= i; j++)
        {
            b[j] = a[j];
        }
        sort(b.rbegin(), b.rend());
        tmp = 0;

        for (int j = 0; j < min(k, i + 1); j++)
        {
            tmp = tmp + b[j];
        }
        tmp = tmp - x * (i + 1);
        if (tmp >= sum)
        {
            sum = tmp;
        }
    }
    cout << sum;
}
0