제출 #1257418

#제출 시각아이디문제언어결과실행 시간메모리
1257418cheetahStove (JOI18_stove)C++20
0 / 100
1 ms2624 KiB
#include <iostream> #include <stdio.h> #include <queue> #include <bits/stdc++.h> #define int long long using namespace std; const int maxn=100005; int n,k; vector<int>pont(maxn),dist(maxn); //in-degreesi en kucuk olandan baslayip guncelleyrek sırayla yazdır bool check(int sure){ int k2=0; int pot=0; int i=1; while(i<n){ pot+=pont[i]-pont[i-1]; if(pot>=sure){ pot=0; i++; k2++; }/* else if(){ }*/ } } int32_t main(){ int t=1; //cin>>t; while(t--){ int n,ans; cin>>n>>k; ans=n; for(int i=0;i<n;i++){ cin>>pont[i]; } if(k>=n){ cout<<1<<endl; continue; } for(int i=0;i<n-1;i++){ dist.push_back(pont[i+1]-pont[i]-1); } sort(dist.begin(),dist.begin()+n); for(int i=0;i<n-k;i++){ ans+=dist[i]; } cout<<ans<<endl; /* int l=1,r=1000000005; while(l<=r){ int mid=(l+r)>>1; if(check(mid)){ r=mid; } else l=mid; } cout<<l<<endl;*/ } }

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

stove.cpp: In function 'bool check(long long int)':
stove.cpp:26:1: warning: no return statement in function returning non-void [-Wreturn-type]
   26 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...