답안 #76858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
76858 2018-09-18T18:16:43 Z Vardanyan Stove (JOI18_stove) C++14
50 / 100
3 ms 764 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 5007;
long long a[N];
long long dif[N];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i = 1;i<=n;i++){
            scanf("%lld",&a[i]);
          if(i>1)  dif[i] = a[i]-a[i-1];
    }
    sort(dif+1,dif+1+n);
    reverse(dif+1,dif+1+n);
    long long c = 0;
    for(int i = 1;i<=k-1;i++)c+=dif[i];
    c = a[n]-a[1]+k-c;
    printf("%lld\n",c);
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
stove.cpp:10:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%lld",&a[i]);
             ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 476 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 476 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 3 ms 544 KB Output is correct
11 Correct 3 ms 576 KB Output is correct
12 Correct 3 ms 596 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 476 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 3 ms 544 KB Output is correct
11 Correct 3 ms 576 KB Output is correct
12 Correct 3 ms 596 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Execution timed out 3 ms 764 KB Time limit exceeded (wall clock)
17 Halted 0 ms 0 KB -