제출 #1229046

#제출 시각아이디문제언어결과실행 시간메모리
1229046xxducdatStove (JOI18_stove)C++20
0 / 100
1 ms320 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
	if(fopen("STOVE.inp", "r")){
		freopen("STOVE.inp", "r", stdin);
		freopen("STOVE.out", "w", stdout);
	}
	int n,k;
	cin>>n>>k;
	vector<int> t(n);
	vector<int> ti;
	for(int i=1;i<=n;i++){
		cin>>t[i];
	}
	for(int i=0;i<n-1;i++){
		ti.push_back(t[i+1]-t[i]-1);
	}
	int T=n;
	sort(ti.begin(),ti.end());
	for(int i=1;i<=n-k;i++){
		T+=ti[i];
	}
	cout<<T;
}

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

stove.cpp: In function 'int main()':
stove.cpp:6:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |                 freopen("STOVE.inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:7:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |                 freopen("STOVE.out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...