Submission #1106188

#TimeUsernameProblemLanguageResultExecution timeMemory
1106188icebearStove (JOI18_stove)C++17
50 / 100
2 ms592 KiB
// ~~ icebear ~~ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef pair<ii, int> iii; #define FOR(i,a,b) for(int i=(a); i<=(b); ++i) #define FORR(i,a,b) for(int i=(a); i>=(b); --i) #define rep(i, n) for(int i=0; i<(n); ++i) #define red(i, n) for(int i=(n)-1; i>=0; --i) #define mp make_pair #define pb push_back #define fi first #define se second #define all(x) x.begin(), x.end() #define task "icebearat" const int MOD = 1e9 + 7; const int inf = 1e9 + 27092008; const ll LLinf = 1e18 + 27092008; const int N = 5000 + 5; int n, k, t[N]; void solve() { cin >> n >> k; FOR(i, 1, n) cin >> t[i]; vector<int> diff(1, -inf); FOR(i, 1, n - 1) diff.pb(t[i + 1] - (t[i] + 1)); sort(all(diff)); ll res = n; FOR(i, 1, n - k) res += diff[i]; cout << res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int tc = 1; // cin >> tc; while(tc--) solve(); return 0; }

Compilation message (stderr)

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