Submission #1033801

# Submission time Handle Problem Language Result Execution time Memory
1033801 2024-07-25T06:32:30 Z vjudge1 Examination (JOI19_examination) C++14
0 / 100
12 ms 2268 KB
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma,lzcnt,popcnt")
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ii pair<int,int>
#define ill pair<ll,ll>
#define el cout<<'\n'
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define int long long
const ll mod=1e9+7;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
const int nmax=1e5;

void add ( int&a , int b ) { if ((a+=b) > mod ) a -= mod ; }
void sub ( int&a , int b ) { if ((a-=b) < 0 ) a += mod ; }

template<typename T> void chkmin(T& x, T y) {if(x > y) x = y;}
template<typename T> void chkmax(T& x, T y) {if(x < y) x = y;}

using namespace std;
signed main()
{
   ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
   int n , k; cin >> n >> k;
	vector<int> a(n+1) , v;
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
		if(i != 1) v.push_back(a[i] - a[i-1] - 1);
	}
	int sum = a[n] - a[1] + 1;
	k--;
	sort(v.begin(),v.end() , greater<int>());
	for(int i = 0 ; i < k ; i++){
		sum -= v[i];
	}
	cout << sum << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 2268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 2268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -