Submission #772399

#TimeUsernameProblemLanguageResultExecution timeMemory
772399RecursiveCoStove (JOI18_stove)C++14
100 / 100
19 ms3612 KiB
// CF template, version 3.0

#include <bits/stdc++.h>

using namespace std;

#define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0)
#define getTest int t; cin >> t
#define eachTest for (int _var=0;_var<t;_var++)
#define get(name) int (name); cin >> (name)
#define out(o) cout << (o)
#define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
#define sortl(name) sort((name).begin(), (name).end())
#define rev(name) reverse((name).begin(), (name).end())
#define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
#define decision(b) if (b){out("YES");}else{out("NO");}

#define int long long int

signed main() {
    improvePerformance;
    get(n);
    get(k);
    k--;
    getList(n, times);
    int ans = times.back() + 1 - times[0];
    vector<int> delta;
    forto(n - 1, i) delta.push_back(times[i + 1] - times[i] - 1);
    sortl(delta);
    rev(delta);
    forto(min(k, n - 1), i) ans -= delta[i];
    out(ans);
}

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:10:23: warning: unnecessary parentheses in declaration of 'n' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
stove.cpp:22:5: note: in expansion of macro 'get'
   22 |     get(n);
      |     ^~~
stove.cpp:10:23: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
stove.cpp:23:5: note: in expansion of macro 'get'
   23 |     get(k);
      |     ^~~
stove.cpp:12:40: warning: unnecessary parentheses in declaration of 'times' [-Wparentheses]
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                        ^
stove.cpp:25:5: note: in expansion of macro 'getList'
   25 |     getList(n, times);
      |     ^~~~~~~
stove.cpp:10:23: warning: unnecessary parentheses in declaration of 'a' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
stove.cpp:12:76: note: in expansion of macro 'get'
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                                                            ^~~
stove.cpp:25:5: note: in expansion of macro 'getList'
   25 |     getList(n, times);
      |     ^~~~~~~
stove.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
stove.cpp:28:5: note: in expansion of macro 'forto'
   28 |     forto(n - 1, i) delta.push_back(times[i + 1] - times[i] - 1);
      |     ^~~~~
stove.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
stove.cpp:31:5: note: in expansion of macro 'forto'
   31 |     forto(min(k, n - 1), i) ans -= delta[i];
      |     ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...