제출 #708428

#제출 시각아이디문제언어결과실행 시간메모리
708428deme_bzStove (JOI18_stove)C++14
0 / 100
1 ms456 KiB
#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define eb emplace_back
#define sz(x) (int)x.size()
using namespace std;
const int N=2e5+5;
 
ll A[N];
void test_case(){
	int n,k;
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		cin >> A[i];
	}
	vector<ll> v;
	for(int i=2;i<=n;i++){
		v.pb(A[i]-A[i-1]-1);
	}
	sort(all(v));
	ll answer=A[n]-A[1]+1;
	for(int i=v.size()-1;i>=v.size()-1-(k-1)+1;i--){
		answer-=v[i];
	}
	cout << answer << endl;
}




main(){
	ios_base::sync_with_stdio(false);
    int T = 1;
    //cin >> T;
    while(T--){
        test_case();
    }
}

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

stove.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
stove.cpp: In function 'void test_case()':
stove.cpp:26:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for(int i=v.size()-1;i>=v.size()-1-(k-1)+1;i--){
      |                       ~^~~~~~~~~~~~~~~~~~~~
stove.cpp: At global scope:
stove.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...