# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209547 | 2020-03-14T14:05:07 Z | kdaojv | Just Long Neckties (JOI20_ho_t1) | C++14 | 5 ms | 256 KB |
#include<bits/stdc++.h> using namespace std; int gu[100010],itv[100010]; int main() { int n,k,i,cnt=1; scanf("%d %d",&n,&k); for(i=1;i<=n;i++){ scanf("%d",&gu[i]); } if(n<=k){ printf("%d",n); return 0; } sort(gu+1,gu+1+n); for(i=2;i<=n;i++){ if(gu[i]-gu[i-1]>1){ cnt++; itv[cnt-1]=gu[i]-gu[i-1]-1; } } if(cnt<=k){ printf("%d",n); return 0; } sort(itv+1,itv+cnt); for(i=1;i<=(cnt-k);i++){ n+=itv[i]; } printf("%d",n); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |