Submission #1208170

#TimeUsernameProblemLanguageResultExecution timeMemory
1208170lmtonayStove (JOI18_stove)C++17
0 / 100
1 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define fast_io \ ios::sync_with_stdio(false); \ cin.tie(NULL); typedef long long ll; const ll INF = 1e18; const ll MOD = 1e9 + 7; const double PI = 3.141592653589793; #define pb push_back #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define endl '\n' #ifndef ONLINE_JUDGE #define debug(x) \ cerr << #x << " = "; \ _print(x); \ cerr << endl; #else #define debug(x) #endif void _print(int x) { cerr << x; } void _print(long x) { cerr << x; } void _print(ll x) { cerr << x; } void _print(unsigned x) { cerr << x; } void _print(unsigned long x) { cerr << x; } void _print(unsigned long long x) { cerr << x; } void _print(float x) { cerr << x; } void _print(double x) { cerr << x; } void _print(long double x) { cerr << x; } void _print(char x) { cerr << '\'' << x << '\''; } void _print(const string &x) { cerr << '"' << x << '"'; } void _print(bool x) { cerr << (x ? "true" : "false"); } template <typename T, typename V> void _print(const pair<T, V> &p) { cerr << '{'; _print(p.first); cerr << ", "; _print(p.second); cerr << '}'; } template <typename T> void _print(const vector<T> &v) { cerr << "[ "; for (const auto &i : v) { _print(i); cerr << " "; } cerr << "]"; } template <typename T> void _print(const set<T> &v) { cerr << "{ "; for (const auto &i : v) { _print(i); cerr << " "; } cerr << "}"; } template <typename T> void _print(const multiset<T> &v) { cerr << "{ "; for (const auto &i : v) { _print(i); cerr << " "; } cerr << "}"; } template <typename T> void _print(const unordered_set<T> &v) { cerr << "{ "; for (const auto &i : v) { _print(i); cerr << " "; } cerr << "}"; } template <typename T, typename V> void _print(const map<T, V> &v) { cerr << "{ "; for (const auto &i : v) { _print(i); cerr << " "; } cerr << "}"; } template <typename T> void _print(const vector<vector<T>> &v) { cerr << "[\n"; for (const auto &row : v) { cerr << " "; _print(row); cerr << "\n"; } cerr << "]"; } int main() { fast_io; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, k; cin >> n >> k; int nums[n + 1] = {0}; for (int i = 1; i <= n; i++) { cin >> nums[i]; } int diff[n] = {0}; for (int i = 1; i < n; i++) { diff[i] = nums[i + 1] - nums[i]; } sort(diff, diff + n); ll sum = 0; for (int i = 0; i < k; i++) { sum += diff[i] + 1; } cout << sum << endl; return 0; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:124:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  124 |   freopen("input.txt", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:125:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  125 |   freopen("output.txt", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...