Submission #45144271


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
// #define MOD 998244353
int dx[8] = {0, 0, -1, 1, 1, 1, -1, -1};
int dy[8] = {-1, 1, 0, 0, 1, -1, 1, -1};
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
const long long MOD = 1000000007;
const int SIZE = 150;
// ↑templete

signed main()
{
    ll N, D, P;
    cin >> N >> D >> P;
    vll F;
    for (int i = 0; i < N; i++)
    {
        int f;
        cin >> f;
        F.push_back(f);
    }

    sort(F.begin(), F.end());

    ll mini = (N + D - 1) / D * P;
    ll sum = 0;
    for (int i = 0; i < N; i++)
    {
        ll f = F[i];
        ll pass = (N - i + D - 2) / D * P;
        sum += f;
        mini = min(mini, pass + sum);
        // cout << pass << " " << sum << " " << mini << endl;
    }
    cout << mini << endl;
    return 0;
}

Submission Info

Submission Time
Task C - Blue Spring
User takeo1116
Language C++ 20 (gcc 12.2)
Score 300
Code Size 920 Byte
Status AC
Exec Time 62 ms
Memory 5296 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 36
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, random_00.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, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3500 KiB
example_01.txt AC 1 ms 3496 KiB
example_02.txt AC 1 ms 3456 KiB
hand_00.txt AC 55 ms 5264 KiB
hand_01.txt AC 55 ms 5212 KiB
hand_02.txt AC 21 ms 5212 KiB
hand_03.txt AC 1 ms 3360 KiB
hand_04.txt AC 1 ms 3424 KiB
hand_05.txt AC 1 ms 3460 KiB
hand_06.txt AC 1 ms 3464 KiB
hand_07.txt AC 1 ms 3648 KiB
random_00.txt AC 62 ms 5212 KiB
random_01.txt AC 61 ms 5152 KiB
random_02.txt AC 59 ms 5296 KiB
random_03.txt AC 56 ms 5196 KiB
random_04.txt AC 50 ms 5120 KiB
random_05.txt AC 44 ms 5208 KiB
random_06.txt AC 40 ms 5172 KiB
random_07.txt AC 62 ms 5164 KiB
random_08.txt AC 60 ms 5240 KiB
random_09.txt AC 59 ms 5244 KiB
random_10.txt AC 57 ms 5260 KiB
random_11.txt AC 52 ms 5148 KiB
random_12.txt AC 44 ms 5280 KiB
random_13.txt AC 40 ms 5264 KiB
random_14.txt AC 62 ms 5148 KiB
random_15.txt AC 61 ms 5196 KiB
random_16.txt AC 60 ms 5148 KiB
random_17.txt AC 53 ms 5148 KiB
random_18.txt AC 51 ms 5216 KiB
random_19.txt AC 44 ms 5116 KiB
random_20.txt AC 40 ms 5152 KiB
random_21.txt AC 62 ms 5244 KiB
random_22.txt AC 60 ms 5212 KiB
random_23.txt AC 59 ms 5152 KiB
random_24.txt AC 56 ms 5220 KiB