Submission #971720

#TimeUsernameProblemLanguageResultExecution timeMemory
971720nguyentunglamMeasures (CEOI22_measures)C++17
0 / 100
1554 ms348 KiB
#include<bits/stdc++.h> #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const int N = 2e5 + 30; int n, m, d; int a[N]; int32_t main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } if (fopen(task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } cin >> n >> m >> d; d *= 2; for(int i = 1; i <= n; i++) cin >> a[i], a[i] *= 2; auto calc = [&] () { for(int i = 1; i <= n; i++) sort(a + 1, a + n + 1); auto check = [&] (int time) { int last = -1e9; for(int i = 1; i <= n; i++) { if (a[i] + time < last + d) return false; last = max(last + d, a[i] - time); } }; int l = 0, r = 2e9, last = -1; while (l <= r) { int mid = l + r >> 1; if (check(mid)) { last = mid; r = mid - 1; } else l = mid + 1; } return last; }; while (m--) { ++n; cin >> a[n]; a[n] *= 2; int ret = calc(); cout << ret / 2; if (ret % 2) cout << ".5"; cout << " "; } }

Compilation message (stderr)

Main.cpp: In lambda function:
Main.cpp:46:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |       int mid = l + r >> 1;
      |                 ~~^~~
Main.cpp: In function 'int32_t main()':
Main.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen("task.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen("task.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen (task".inp", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:24:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     freopen (task".out", "w", stdout);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In lambda function:
Main.cpp:42:5: warning: control reaches end of non-void function [-Wreturn-type]
   42 |     };
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...