Submission #974577

#TimeUsernameProblemLanguageResultExecution timeMemory
974577FIFI_cppStove (JOI18_stove)C++17
100 / 100
37 ms2300 KiB
#include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <cstdlib> #include <cmath> #include <queue> #include <stack> #include <deque> #include <fstream> #include <iterator> #include <set> #include <map> #include <unordered_map> #include <iomanip> #include <cctype> #include <string> #include <cassert> #include <set> #include <bitset> #include <unordered_set> using ll = long long; #define pb push_back #define all(a) a.begin(),a.end() #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); // xcode cant include bits/stdc++.h using namespace std; //ifstream fin ("fenceplan.in"); //ofstream fout ("fenceplan.out"); /* /\_/\ * (= ._.) * / > \> */ // encouraging cat const ll INF = 100000000000000; const ll mod = 1000000007; int main() { int n,k; cin >> n >> k; vector<int> nums(n,0); for (int i = 0;i < n;i++) cin >> nums[i]; vector<int> intervals(n - 1,0); for (int i = 1;i < n;i++) { intervals[i - 1] = (nums[i] - (nums[i - 1] + 1)); } sort(all(intervals)); int cost = n; for (int i = 0;i < n - k;i++) { cost += intervals[i]; } cout << cost << '\n'; return 0; }

Compilation message (stderr)

stove.cpp:30:9: warning: "/*" within comment [-Wcomment]
   30 | /*   /\_/\
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...