#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ull n,k;
cin >> n >> k;
vector <ull> a(n),pref(n);
ull num;
for(ull i = 0; i < n; i++)
{
cin >> a[i];
if(i == 0) num = a[0];
pref[i] = a[i] - num;
}
if(k == n)
{
cout << n;
}
else if(k == 1)
{
cout << pref[n - 1] + 1;
}
else
{
ull sum = 0;
sum += pref[k - 1];
sum += n - k;
if(n - k == 1) sum++;
cout << sum;
}
return 0;
}
/*
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |