QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#54619#3123. Stovelmeowdn0 2ms3700kbC++17815b2022-10-09 21:00:232022-10-09 21:00:26

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-09 21:00:26]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:3700kb
  • [2022-10-09 21:00:23]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define eb emplace_back
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef unsigned long long ull;
 
long long read() {
    long long res=0, w=1; char c=getchar();
    while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
    while(isdigit(c)) {res=res*10+c-48, c=getchar();}
    return res*w;
}

const int N=1e5+9;
int n,k,a[N],b[N],ans;

signed main() {
    n=read(), k=read();
    rep(i,1,n) a[i]=read();
    rep(i,1,n-1) b[i]=a[i+1]-a[i]-1;
    ans=a[n];
    sort(b+1,b+n,greater<int>());
    rep(i,1,k-1) ans-=b[i];
    printf("%lld\n",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 20
Accepted
time: 1ms
memory: 3700kb

input:

10 1
1
3
4
6
8
10
13
14
15
20

output:

20

result:

ok single line: '20'

Test #2:

score: -20
Wrong Answer
time: 2ms
memory: 3656kb

input:

10 3
2
3
6
9
10
11
13
14
17
18

output:

14

result:

wrong answer 1st lines differ - expected: '13', found: '14'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%