QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#112257#6564. Frequent FlierITMO_pengzoo#WA 80ms15720kbC++201.7kb2023-06-10 22:47:342023-06-10 22:47:37

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-10 22:47:37]
  • 评测
  • 测评结果:WA
  • 用时:80ms
  • 内存:15720kb
  • [2023-06-10 22:47:34]
  • 提交

answer

//  Nikita Golikov, 2023

#include <bits/stdc++.h>

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#ifdef GOLIKOV
  #include "/Users/golikovnik/contests/debug.h"
#else
  #define debug(...) ;
#endif

template <class A, class B>
bool smin(A& x, B&& y) {
  if (y < x) {
    x = y;
    return true;
  }
  return false;
}

template <class A, class B>
bool smax(A& x, B&& y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int main() {
#ifdef GOLIKOV
  assert(freopen("in", "rt", stdin));
  auto _clock_start = chrono::high_resolution_clock::now();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n);
  for (auto& x : a) cin >> x;
  vector<ll> cnt(n);
  ll cur = 0;
  set<int> notFull;
  for (int i = 0; i < n; ++i) {
    notFull.insert(i);
  }
  for (int i = 0; i - (m - 1) < n; ++i) {
    debug(i, cur);
    while (cur < k) {
      auto it = notFull.upper_bound(i);
      if (it != notFull.begin()) {
        --it;
        int j = *it;
        ll use = min(k - cur, a[j] - cnt[j]);
        cnt[j] += use;
        cur += use;
        if (cnt[j] == a[j]) {
          notFull.erase(j);
        }
      } else {
        break;
      }
    }
    debug(cur);
    if (i >= m - 1) {
      cur -= cnt[i - (m - 1)];
    }
  }
  debug(cnt);
  cout << accumulate(cnt.begin(), cnt.end(), 0ll) << '\n';

#ifdef GOLIKOV
  cerr << "Executed in " << chrono::duration_cast<chrono::milliseconds>(
      chrono::high_resolution_clock::now()
          - _clock_start).count() << "ms." << endl;
#endif
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3408kb

input:

8 3 2
3
1
4
1
5
9
2
6

output:

8

result:

ok single line: '8'

Test #2:

score: -100
Wrong Answer
time: 80ms
memory: 15720kb

input:

200000 2467 999931035
182548858
69876218
33328350
919486767
739850600
948199964
392292320
39077742
366752074
917496841
246661698
37219034
56677740
188278971
965701828
28059790
13200243
825730775
542597589
320715170
939054378
470563899
914247467
990100491
290827128
903662394
611104879
18631185
412134...

output:

83896397570

result:

wrong answer 1st lines differ - expected: '82994275905', found: '83896397570'