제출 #531181

#제출 시각아이디문제언어결과실행 시간메모리
531181nguotStove (JOI18_stove)C++14
100 / 100
64 ms2796 KiB
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l,int r){return l+rng()%(r-l+1);} #define fasty ios_base::sync_with_stdio(0),cin.tie(0) #define fori(x,a,b) for (int x=a;x<=b;x++) #define ford(x,a,b) for (int x=a;x>=b;x--) #define forv(a,b) for(auto&a:b) #define fi first #define se second #define pb push_back #define ii pair<int,int> #define mt make_tuple #define mp make_pair #define all(a) a.begin(),a.end() #define reset(f,x) memset(f, x, sizeof(f)) #define getbit(x,i) ((x>>i)&1) #define batbit(x,i) (x|(1ll<<i)) #define tatbit(x,i) (x&~(1<<i)) #define gg exit(0); #define int long long const int N = 3e5+10; int n,a[N],b[N],k; main() { int n,k; cin>>n>>k; --k; fori(i,1,n) cin>>a[i]; fori(i,1,n-1) b[i] = a[i+1]-a[i]-1; int res = a[n]-a[1]+1; sort(b+1,b+n+1,greater<int>()); fori(i,1,k) res-=b[i]; cout<<res; } //xem lai lqdoj //cai lai voi19

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

stove.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   25 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...