| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 778883 | vjudge1 | Stove (JOI18_stove) | C++17 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(), x.end()
#define len(x) x.size()
#define forik(x) ll i = 1; i <= x; i++
const int mod = 1e9 + 7;
using namespace std;
ll n, k, p[200001], ans;
vector <ll> v;
ll gcd (ll a, ll b){
while (a > 0 && b > 0){
if (a >= b){
a %= b;
}
else{
b %= a;
}
}
return a + b;
}
ll binpow(ll a, ll b){
a %= mod;
if(b == 0){
return 1;
}
if(b % 2 == 1){
return binpow (a, b - 1) % mod * a;
}
if(b % 2 == 0){
ll t = binpow (a, b / 2) % mod;
return t * t % mod;
}
}
signed main (){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++){
cin >> p[i];
}
for (int i = 1; i < n; i++){
if (i == 1){
v.pb(p[i + 1] - p[i] + 1);
}
else {
v.pb (p[i + 1] - p[i]);
}
}
k--;
if (n - 1 <= k){
cout << n;
return 0;
}
sort (all(v));
for (int i = len(v) - 1; i >= v.size() - k; i--){
v[i] = 1;
}
for (int i = 0; i < len(v); i++){
ans += v[i];
}
cout << ans;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
