Submission #1241433

#TimeUsernameProblemLanguageResultExecution timeMemory
1241433tminhStove (JOI18_stove)C++20
100 / 100
12 ms1480 KiB
/* Em la may troi trong gio Anh la cay nhieu dan do */ #include "bits/stdc++.h" using namespace std; #define ll long long #define endl '\n' #define fi first #define se second #define vall(a) (a).begin(), (a).end() #define sze(a) (int)a.size() #define pii pair<int, int> #define ep emplace_back #define pb push_back #define pf push_front const int mod = 1e9 + 7; const signed N = 1e6 + 5; const ll oo = 1e18; int n, k, t[N]; vector<int> arr; void output() { int total = (t[n] - t[1] + 1); for (int i = 2; i <= n; ++i) arr.pb(t[i] - (t[i - 1] + 1)); sort(vall(arr), greater<int>()); for (int i = 0; i < k; ++i) total -= arr[i]; cout << total; return; } void input() { cin >> n >> k; for (int i = 1; i <= n; ++i) cin >> t[i]; --k; output(); return; } signed main() { if(fopen("", "r")) { freopen("", "r", stdin); freopen("", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); input(); cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << 's' << endl; return 0; }

Compilation message (stderr)

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