Submission #971727

# Submission time Handle Problem Language Result Execution time Memory
971727 2024-04-29T08:19:00 Z nguyentunglam Measures (CEOI22_measures) C++17
24 / 100
1500 ms 3964 KB
#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;

long long 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 = [&] () {
    sort(a + 1, a + n + 1);

    auto check = [&] (long long time) {
      long long last = -1e18;
      for(int i = 1; i <= n; i++) {
        if (a[i] + time < last + d) return false;
        last =  max(last + d, a[i] - time);
      }
      return true;
    };

    long long l = 0, r = 1e17, last = -1;
    while (l <= r) {
      long long 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;
    long long ret = calc();
    cout << ret / 2;
    if (ret % 2) cout << ".5";
    cout << " ";
  }
}



Compilation message

Main.cpp: In lambda function:
Main.cpp:48:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |       long long 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);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 230 ms 1824 KB Output is correct
10 Correct 275 ms 3944 KB Output is correct
11 Correct 178 ms 3964 KB Output is correct
12 Correct 293 ms 3932 KB Output is correct
13 Correct 185 ms 3476 KB Output is correct
14 Correct 224 ms 3916 KB Output is correct
15 Correct 226 ms 3264 KB Output is correct
16 Correct 179 ms 3932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1598 ms 756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1598 ms 756 KB Time limit exceeded
2 Halted 0 ms 0 KB -