Submission #255010

#TimeUsernameProblemLanguageResultExecution timeMemory
255010shrek12357Stove (JOI18_stove)C++14
100 / 100
74 ms2648 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <climits> #include <cmath> #include <fstream> #include <queue> using namespace std; bool comp(int a, int b) { return a > b; } int main() { int n, k; cin >> n >> k; vector<int> times; for (int i = 0; i < n; i++) { int temp; cin >> temp; times.push_back(temp); } sort(times.begin(), times.end()); int tot = 1; vector<int> diff; for (int i = 1; i < times.size(); i++) { diff.push_back(times[i] - times[i - 1]); tot += times[i] - times[i - 1]; } sort(diff.begin(), diff.end(), comp); for (int i = 0; i < k - 1; i++) { tot -= diff[i]; tot++; } cout << tot << endl; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:28:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < times.size(); i++) {
                  ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...