Submission #772399

# Submission time Handle Problem Language Result Execution time Memory
772399 2023-07-04T05:22:35 Z RecursiveCo Stove (JOI18_stove) C++14
100 / 100
19 ms 3612 KB
// 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

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 time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 18 ms 3536 KB Output is correct
17 Correct 15 ms 3536 KB Output is correct
18 Correct 19 ms 3612 KB Output is correct
19 Correct 15 ms 3524 KB Output is correct
20 Correct 17 ms 3516 KB Output is correct
21 Correct 18 ms 3576 KB Output is correct
22 Correct 15 ms 3564 KB Output is correct
23 Correct 16 ms 3604 KB Output is correct
24 Correct 16 ms 3536 KB Output is correct