QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#439792#4403. MeasuresSmilingBraniac#0 32ms9228kbC++141.2kb2024-06-12 18:08:552024-06-12 18:08:56

Judging History

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

  • [2024-06-12 18:08:56]
  • 评测
  • 测评结果:0
  • 用时:32ms
  • 内存:9228kb
  • [2024-06-12 18:08:55]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll f(ll s, ll e, ll sz, ll d) {
    return (d * (sz - 1) - (e - s)) / 2;
}

ll solve(ll n, ll d, vector<ll> v) {
    d *= 2;
    for (ll& i : v) i *= 2;
    sort(v.begin(), v.end());
    stack<ll> s, e, sz;
    for (int i = 0; i < n; ++i) {
        ll a = v[i], b = v[i], cnt = 1ll;
        while (!s.empty()) {
            ll add = f(s.top(), e.top(), sz.top(), d), neg = f(a, b, cnt, d);
            if (e.top() + add + d <= a - neg) break;
            a = s.top();
            cnt += sz.top();
            s.pop(); e.pop(); sz.pop();
        }
        s.push(a); e.push(b); sz.push(cnt);
    }
    ll ans = 0;
    while (!s.empty()) {
        ans = max(ans, f(s.top(), e.top(), sz.top(), d));
        s.pop(); e.pop(); sz.pop();
    }
    return ans;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    ll n, q, d; cin >> n >> q >> d;
    vector<ll> v(n);
    //for (ll& i : v) cin >> i;
    for (int i = 0; i < n; ++i) v[i] = i;
    while (q--) {
        ll x; cin >> x;
        v.push_back(x);
        ll ans = solve(v.size(), d, v);
        cout << ans / 2;
        if (ans & 1) cout << ".5";
        cout << ' ';
    }
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3668kb

input:

2000 10 1845
533219610 452539353 832124174 883897563 447321676 368976465 166536135 758380924 920827481 313174994 781707618 815047867 925081003 325012331 69086835 637564067 429273345 781597586 376641056 72157101 36547962 656170271 772458737 707141316 33546435 166034841 747620387 663158697 852912826 9...

output:

1843078 1843078 1843078 1843078 1843078 1843078 1843078 1843078 1843078 1843078 

result:

wrong answer 1st lines differ - expected: '841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5', found: '1843078 1843078 1843078 184307...843078 1843078 1843078 1843078 '

Subtask #2:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 32ms
memory: 9228kb

input:

200000 10 128
853561279 93820692 821887507 753094209 227461682 691969137 519378763 296675314 646705609 727762559 98496302 959430593 403972779 982596953 775241610 209602833 112152326 762927950 619981024 764326855 379819398 392809293 145648647 960106249 514225957 952027167 428472167 571874662 95085242...

output:

12699936.5 12699936.5 12699936.5 12699936.5 12699936.5 12699936.5 12699936.5 12699936.5 12699936.5 12699936.5 

result:

wrong answer 1st lines differ - expected: '167 167 167 167 167 167 167 167 167 167', found: '12699936.5 12699936.5 12699936...699936.5 12699936.5 12699936.5 '

Subtask #3:

score: 0
Time Limit Exceeded

Test #17:

score: 0
Time Limit Exceeded

input:

0 200000 1289

3822 6378 8930 10621 14339 15484 27804 30714 47103 51268 51740 57420 74974 81161 81292 82797 84329 92397 96558 102781 108313 117355 117730 121011 121917 123170 124479 132083 144850 152609 153404 161406 162584 163062 172029 172074 172504 178451 185861 197247 197729 204944 223883 245287...

output:

0 0 0 0 0 72 72 72 72 72 408.5 408.5 408.5 408.5 579 471 408.5 408.5 408.5 408.5 408.5 408.5 457 457 457 457 457 457 457 457 457 457 457 461 461 622 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051.5 1051...

result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #34:

score: 0
Time Limit Exceeded

input:

0 200000 1289

582772771 851704216 915624354 601264573 510202549 844706968 795870015 897865316 665295826 172582259 59358299 239645315 343442424 973625659 840972987 546781500 897704802 602265737 968590815 561687707 728916679 417806750 143659623 620408739 86393298 403049850 578760184 735385586 7656173...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result: