답안 #1102412

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102412 2024-10-18T05:01:52 Z adiyer Stove (JOI18_stove) C++17
0 / 100
1 ms 340 KB
#pragma optimize ("g",on)
#pragma GCC optimize("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
 
#include <bits/stdc++.h>

#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout);
#define adiyer(); ios_base::sync_with_stdio(0); cin.tie(0);
#define bitcount(n) __builtin_popcountll(n)
#define puts(x) a << (x ? "YES\n" : "NO\n");
#define ent (i == n ? '\n' : ' ')
#define all(x) x.begin(), x.end()
#define md ((l + r) >> 1)
#define rv(v) ((v << 1) | 1)
#define lv(v) (v << 1)
#define rs(v) rv(v), md + 1, r
#define ls(v) lv(v), l, md
#define len(s) (int) s.size()
 
#define yes {cout << "YES\n"; return; }
#define no {cout << "no\n"; return; } 
#define skip continue
#define pb push_back
#define S second
#define F first
#define ne !=

// #define int long long
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector < ll > vll;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;

const int dx[8] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
const int N = 1e5 + 12;
const int K = 5e3 + 12;
const int MAX = 5e3;
const int mod = 1e9 + 7;
const ll inf = 2e18 + 10;
const ll o = 1;
 
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll n, k, ans;
ll a[N];

vll v;

void output(){
	cin >> n >> k;
	for(ll i = 1; i <= n; i++) cin >> a[i];
	for(ll i = 2; i <= n; i++) v.pb(a[i] - a[i - 1] - 1);
	sort(all(v));
	reverse(all(v));
	for(ll i = 0; i < min(len(v) + 0ll, k - 1); i++) ans += v[i];
	cout << a[n] - ans;
	
}
   
const bool cases = 0;

signed main(){
    // file("disrupt");
    adiyer();
	int tt = 1;
    if(cases) cin >> tt;
    for(int i = 1; i <= tt; i++){
        // cout << "Case " << i << ":\n";
    	output();
    }
}	

Compilation message

stove.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize ("g",on)
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -