Submission #702374

#TimeUsernameProblemLanguageResultExecution timeMemory
702374m_fenaisStove (JOI18_stove)C++17
100 / 100
53 ms3176 KiB
#include <bits/stdc++.h> #define endl '\n' #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define int long long using namespace std; const int N = 100000 + 10, mod = 1e9 + 7; int n, k, a[N], ans; vector<int> v; signed main() { cin >> n >> k; ans += n; for(int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for(int i = 1; i < n; i++) if(a[i] - a[i-1] > 1) v.push_back(a[i] - a[i-1] - 1); sort(v.begin(), v.end()); k--; if(k < v.size()) for(int i = 0; i < v.size() - k; i++) ans += v[i]; cout << ans << endl; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:17:7: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  if(k < v.size()) for(int i = 0; i < v.size() - k; i++) ans += v[i];
      |     ~~^~~~~~~~~~
stove.cpp:17:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   17 |  if(k < v.size()) for(int i = 0; i < v.size() - k; i++) ans += v[i];
      |                                  ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...