답안 #978245

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978245 2024-05-09T04:39:24 Z PkiraX Stove (JOI18_stove) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+5;
ll n,k;
ll val;
ll x[N];
priority_queue <ll> pq;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    for(int i=1;i<=n;i++) cin >> x[i];
    sort(x+1,x+1+n);
    for(int i=1;i<n;i++) 3{
        pq.push(x[i+1] - (x[i]+1));
    }
    val = (x[n] - x[1]) + 1;
    for(int i=1;i<=k-1;i++){
        val -= pq.top();
        pq.pop();
    }
    cout << val;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:15:27: error: expected ';' before '{' token
   15 |     for(int i=1;i<n;i++) 3{
      |                           ^
      |                           ;
stove.cpp:15:26: warning: statement has no effect [-Wunused-value]
   15 |     for(int i=1;i<n;i++) 3{
      |                          ^