제출 #1229023

#제출 시각아이디문제언어결과실행 시간메모리
1229023kokokaiStove (JOI18_stove)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+4;

int main(){
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    if(fopen("task.inp","r")){
      freopen("task.inp","r",stdin)
    }
    int n,k;
    cin>>n>>k;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    if(n==1){
        cout<<1<<'\n';
        return 0;
    }
    priority_queue<int> pq;
    for(int i=2;i<=n;i++) pq.push(a[i]-a[i-1]);
    int ans=a[n]-a[1]+1;
    for(int i=2;i<=k;i++){
        int mx=pq.top();
        pq.pop();
        ans++;
        ans-=mx;
    }
    cout<<ans<<'\n';
}

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

stove.cpp: In function 'int main()':
stove.cpp:8:36: error: expected ';' before '}' token
    8 |       freopen("task.inp","r",stdin)
      |                                    ^
      |                                    ;
    9 |     }
      |     ~                               
stove.cpp:8:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |       freopen("task.inp","r",stdin)
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~