제출 #66722

#제출 시각아이디문제언어결과실행 시간메모리
66722hamzqq9Stove (JOI18_stove)C++14
100 / 100
34 ms1764 KiB
#include<bits/stdc++.h> #define st first #define nd second #define pb push_back #define ppb pop_back #define umax(x,y) x=max(x,y) #define umin(x,y) x=min(x,y) #define ll long long #define ii pair<int,int> #define iii pair<int,ii> #define sz(x) ((int) x.size()) #define orta ((bas+son)>>1) #define all(x) x.begin(),x.end() #define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" " #define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar() #define pw(x) (1<<(x)) #define inf 1000000000000000 #define MOD 1000000007 #define N 100005 #define MAX 10000006 #define LOG 22 using namespace std; int n,k; int a[N]; vector<int> e; int main() { // freopen("input.txt","r",stdin); scanf("%d %d",&n,&k); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); } sort(a+1,a+1+n); int comp=n; for(int i=1;i<n;i++) { e.pb(abs(a[i]-a[i+1])); } sort(all(e)); int ans=n; int cur=0; while(comp>k) { comp--; ans+=e[cur]-1; cur++; } printf("%d\n",ans); }

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

stove.cpp: In function 'int main()':
stove.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~
stove.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...