답안 #971758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971758 2024-04-29T09:01:18 Z nguyentunglam Measures (CEOI22_measures) C++17
0 / 100
1500 ms 512 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;

  for(int i = 1; i <= n; i++) cin >> a[i];


  auto calc = [&] () {
    sort(a + 1, a + n + 1);

    long long ans = 0;

    for(int i = 1; i <= n; i++) for(int j = i + 1; j <= n; j++) {
      ans = max(ans, (j - i) * d - a[j] + a[i]);
    }

    return ans;
  };

  while (m--) {
    ++n;
    cin >> a[n];
    long long ret = calc();
    cout << ret / 2;
    if (ret % 2) cout << ".5";
    cout << " ";
  }
}



Compilation message

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);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 344 KB Output is correct
2 Correct 24 ms 348 KB Output is correct
3 Correct 25 ms 348 KB Output is correct
4 Correct 26 ms 496 KB Output is correct
5 Correct 24 ms 480 KB Output is correct
6 Correct 26 ms 344 KB Output is correct
7 Correct 25 ms 348 KB Output is correct
8 Incorrect 25 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 344 KB Output is correct
2 Correct 24 ms 348 KB Output is correct
3 Correct 25 ms 348 KB Output is correct
4 Correct 26 ms 496 KB Output is correct
5 Correct 24 ms 480 KB Output is correct
6 Correct 26 ms 344 KB Output is correct
7 Correct 25 ms 348 KB Output is correct
8 Incorrect 25 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1544 ms 512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1544 ms 512 KB Time limit exceeded
2 Halted 0 ms 0 KB -