Submission #737267

#TimeUsernameProblemLanguageResultExecution timeMemory
737267AmaarsaaStove (JOI18_stove)C++14
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n, m, ans, x, y, i, j; cin >> n >> m; int a[n + 2]; ans = 0; vector < int > v; for ( i = 1; i <= n; i ++) { cin >> a[i]; if ( i > 1) { v.push_back(a[i] - a[i - 1]); } } ans = a[n] - a[1] + 1; sort (v.begin(), v.end()); for (i = v.size() - 1; i >= v.size() - (m - 1); i --) { ans -= (v[i] - 1); } cout << ans << endl; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:20:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for (i = v.size() - 1; i >= v.size() - (m - 1); i --) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~~
stove.cpp:5:17: warning: unused variable 'x' [-Wunused-variable]
    5 |  int n, m, ans, x, y, i, j;
      |                 ^
stove.cpp:5:20: warning: unused variable 'y' [-Wunused-variable]
    5 |  int n, m, ans, x, y, i, j;
      |                    ^
stove.cpp:5:26: warning: unused variable 'j' [-Wunused-variable]
    5 |  int n, m, ans, x, y, i, j;
      |                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...