Submission #9450861


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool isInField(int x, int y, int h, int w) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, k, m;
    cin >> n >> k >> m;
    vector<ll> a(n - 1);
    for (size_t i = 0; i < n - 1; i++)
    {
        cin >> a[i];
    }

    ll target = n * m;
    ll sum = accumulate(a.begin(), a.end(), 0);
    if (0 <= target - sum && target - sum <= k) {
        cout << target - sum << "\n";
    }
    else if (target - sum < 0) {
        cout << 0 << "\n";
    }
    else {
        cout << -1 << "\n";
    }


    return 0;
}

Submission Info

Submission Time
Task B - Achieve the Goal
User mmatthew_43
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1359 Byte
Status
Exec Time 1 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01, sample_02, sample_03
All 200 / 200 hand_01, hand_02, hand_03, hand_04, max_01, max_02, max_03, min_01, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, random_11, random_12, random_13, random_14, random_15, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
hand_01 1 ms 256 KB
hand_02 1 ms 256 KB
hand_03 1 ms 256 KB
hand_04 1 ms 256 KB
max_01 1 ms 256 KB
max_02 1 ms 256 KB
max_03 1 ms 256 KB
min_01 1 ms 256 KB
random_01 1 ms 256 KB
random_02 1 ms 256 KB
random_03 1 ms 256 KB
random_04 1 ms 256 KB
random_05 1 ms 256 KB
random_06 1 ms 256 KB
random_07 1 ms 256 KB
random_08 1 ms 256 KB
random_09 1 ms 256 KB
random_10 1 ms 256 KB
random_11 1 ms 256 KB
random_12 1 ms 256 KB
random_13 1 ms 256 KB
random_14 1 ms 256 KB
random_15 1 ms 256 KB
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
sample_03 1 ms 256 KB