제출 #318811

#제출 시각아이디문제언어결과실행 시간메모리
318811vojinStove (JOI18_stove)C++14
0 / 100
1 ms364 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...