Submission #419252

# Submission time Handle Problem Language Result Execution time Memory
419252 2021-06-06T15:29:45 Z Lobo Stove (JOI18_stove) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
 
using namespace std;

const long long INFll = 1e18;
const int INFii = 1e9;
typedef long long ll;
typedef int ii;
typedef double dbl;
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back

#define maxn 1
//LEMBRAR DE MUDAR

ii n, k, ant, g[maxn];


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

    //freopen("in.in", "r", stdin);
    //freopen("____.out", "w", stdout);

    cin >> n >> k;
    cin >> ant;

    ii ans = 1;
    for(ii i = 1; i <= n; i++) {
        ii t;
        cin >> t;

        g[i] = t-ant-1;
        ans+= g[i] + 1;
        ant = t;
    }

    sort(g+1,g+1+n,greater<ii>());

    k--;
    for(ii i = 1; i <= k; i++) {
        ans-= g[i];
    }

    cout << ans << endl;
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:45:18: warning: array subscript 1 is above array bounds of 'ii [1]' {aka 'int [1]'} [-Warray-bounds]
   45 |         ans-= g[i];
      |               ~~~^
stove.cpp:19:15: note: while referencing 'g'
   19 | ii n, k, ant, g[maxn];
      |               ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -