Submission #990577

#TimeUsernameProblemLanguageResultExecution timeMemory
990577StuckOnAStove (JOI18_stove)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define pf(x, y) (x).insert((x).begin(), y) #define int long long #define nosync() ios_base::sync_with_stdio(false); cin.tie(NULL); #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define db(x) cerr << #x << " = " << x << endl; #define duck cerr << "Duck" << endl; #define __ << ' ' << #define endl '\n' #define tcT template<class T #define mp make_pair #define f first #define s second #define cyn(x) cout << (x ? "YES" : "NO") << endl; //#define remove_debug using str = string; using pi = pair<int, int>; using vi = vector<int>; using vs = vector<str>; using vpi = vector<pi>; using si = set<int>; using mi = map<int, int>; using mc = map<char, int>; using ms = map<str, int>; tcT > void input (vector<T> &x) { for (auto &i : x) cin >> i; } tcT > void print (T x) { for (auto i : x) cout << i << ' '; cout << endl; } tcT > void printfs (T x) { for (auto i : x) cout << i.f __ i.s << endl; } tcT > void empty (T x) {} #ifdef remove_debug #define cerr if(false) cerr #define print(x) empty(x) #define printfs(x) empty(x) #endif void init() { fclose(fopen("output.txt", "w")); freopen("input.txt", "r", stdin); freopen("output.txt", "a", stdout); freopen("output.txt", "a", stderr); } void usaco(char *S) { char I[99],O[99]; sprintf(I,"%s.in",S); sprintf(O,"%s.out",S); freopen(I,"r",stdin); freopen(O,"w",stdout); } void solve() { int n, k; cin >> n >> k; vi v(n), vd(n - 1); input(v); for (int i = 0; i < n - 1; i++) vd[i] = v[i + 1] - v[i] - 1; sort(rall(vd)); int sum = 0; for (int i = 0; i < k - 1; i++) sum += vd[i]; cout << *max_element(all(v)) - sum << endl; } signed main() { nosync(); #ifdef local init(); #else //usaco("task_name"); #endif int t = 1; //cin >> t; for (int c = 1; c <= t; c++) { //cerr << "Case" << c << ": "; solve(); } return 0; }

Compilation message (stderr)

stove.cpp: In function 'void init()':
stove.cpp:58:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |  freopen("input.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:59:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |  freopen("output.txt", "a", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:60:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |  freopen("output.txt", "a", stderr);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp: In function 'void usaco(char*)':
stove.cpp:68:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |  freopen(I,"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~
stove.cpp:69:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |  freopen(O,"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...