Submission #931891

# Submission time Handle Problem Language Result Execution time Memory
931891 2024-02-22T14:13:53 Z lovrot Stove (JOI18_stove) C++17
0 / 100
0 ms 348 KB
#include <cstdio> 
#include <algorithm> 
#include <cstring> 
#include <cmath> 
#include <iostream> 
#include <set> 
#include <queue> 
#include <deque> 
#include <vector> 
#include <random> 
#include <chrono> 

#define X first
#define Y second
#define PB push_back
#define EB emplace_back

using namespace std; 

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MOD = 1e9 + 7; // 998 244 353;
const int N = 1e5 + 10;

int n, k, A[N];

int main() {
	scanf("%d%d", &n, &k); 
	int lst = 0, ans = 0;
	for(int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x); 
		A[i] = x - lst - 1;
		if(!i) ans -= x;
		if(i == n - 1) ans += x + 1;
		lst = x;
	}
	sort(A + 1, A + n, [](int a, int b) { return a > b; });
	for(; k; k--) ans -= A[k];
	printf("%d\n", ans);
	return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
stove.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |   scanf("%d", &x);
      |   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -