Submission #171700

#TimeUsernameProblemLanguageResultExecution timeMemory
171700dennisstarStove (JOI18_stove)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

int n, k, t[1e5];
priority_queue<int, vector<int>, greater<int> > pq;

int main() {
	scanf("%d %d", &n, &k);
	int ans=n, i;
	for (i=0; i<n; i++) scanf("%d", &t[i]);
	for (i=0; i<n-1; i++) pq.push(t[i+1]-t[i]-1);
	for (i=0; i<n-k; i++) { ans+=pq.top(); pq.pop(); }
	printf("%d\n", ans);
	return 0;
}

Compilation message (stderr)

stove.cpp:4:16: error: size of array 't' has non-integral type 'double'
 int n, k, t[1e5];
                ^
stove.cpp: In function 'int main()':
stove.cpp:8:7: 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:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i=0; i<n; i++) scanf("%d", &t[i]);
                      ~~~~~^~~~~~~~~~~~~