Submission #318811

# Submission time Handle Problem Language Result Execution time Memory
318811 2020-11-03T09:39:42 Z vojin Stove (JOI18_stove) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
#define MAXN (int)1e6
#define FOR(n) for(int i = 0; i < n; i++)
using namespace std;
int a[MAXN],b[MAXN];

int main(){
    int n,k; cin >> n >> k;
    FOR(n) cin >> a[i];

    sort(a,a+n);

    if(k==1) {cout << a[n-1]-a[0]+1 << "\n"; return 0;}
    int niz = 1,m=0;
    for(int i = 0; i < n; i++)if(a[i]+1^a[i+1]) m++;



    cout << n+m-k << "\n";
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:15:38: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   15 |     for(int i = 0; i < n; i++)if(a[i]+1^a[i+1]) m++;
      |                                  ~~~~^~
stove.cpp:14:9: warning: unused variable 'niz' [-Wunused-variable]
   14 |     int niz = 1,m=0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -