답안 #584311

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
584311 2022-06-27T07:57:01 Z Newtech66 Stove (JOI18_stove) C++17
100 / 100
22 ms 2876 KB
#include<bits/stdc++.h>
using namespace std;
using lol=long long int;
#define endl "\n"
const lol mod1=1e9+7,mod2=998244353,mod3=1000000000000000003;
const lol inf=1e18+8;
const double eps=1e-12;
const double PI=acos(-1.0);
const int N=3e5+5;
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<pair<int,int>,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int _=1;
//cin>>_;
while(_--)
{
    int n,k;
    cin>>n>>k;
    vector<lol> v(n);
    for(auto& e:v)  cin>>e;
    vector<lol> d(n-1);
    for(int i=0;i<n-1;i++)  d[i]=v[i+1]-v[i]-1;
    sort(d.rbegin(),d.rend());
    lol S=v[n-1]-v[0]+1;
    for(int i=0;i<k-1;i++)  S-=d[i];
    cout<<S;
}
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 368 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 372 KB Output is correct
13 Correct 1 ms 372 KB Output is correct
14 Correct 1 ms 380 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 368 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 372 KB Output is correct
13 Correct 1 ms 372 KB Output is correct
14 Correct 1 ms 380 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 20 ms 2828 KB Output is correct
17 Correct 18 ms 2772 KB Output is correct
18 Correct 18 ms 2756 KB Output is correct
19 Correct 17 ms 2768 KB Output is correct
20 Correct 18 ms 2876 KB Output is correct
21 Correct 22 ms 2772 KB Output is correct
22 Correct 18 ms 2772 KB Output is correct
23 Correct 17 ms 2772 KB Output is correct
24 Correct 17 ms 2764 KB Output is correct