結果

問題 No.3656 Game Scores and Costs
コンテスト
ユーザー Te
提出日時 2026-09-02 15:19:02
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 889 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,310 ms
コンパイル使用メモリ 359,844 KB
実行使用メモリ 9,780 KB
最終ジャッジ日時 2026-09-02 15:19:11
合計ジャッジ時間 6,483 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
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 = 0;
    long long tmp = 0;
    long long sum = 0;
    cin >> n;
    cin >> k;
    cin >> x;
    vector<int> a(n);
    for (auto &nx : a)
    {
        cin >> nx;
    };
    sum = -9999999999999999;
    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;
}

// N K X
// K は調べる数の数
// A1...AN
// 30 20 70 10 60
// i = 1
// 30 - 20 *1
// i = 2
// 30+ 20 - 20*2
// i - 3
// 30 + 70(70>20) -20*3...
0