QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#439789 | #4403. Measures | SmilingBraniac# | 0 | 179ms | 11296kb | C++14 | 1.2kb | 2024-06-12 18:06:09 | 2024-06-12 18:06:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = double;
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: 10
Accepted
time: 2ms
memory: 4020kb
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:
841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5
result:
ok single line: '841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5 841.5 '
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 3992kb
input:
2000 10 18453 15731 19943 24157 28373 32591 36811 41033 45257 49483 53711 57941 62173 66407 70643 74881 79121 83363 87607 91853 96101 100351 104603 108857 113113 117371 121631 125893 130157 134423 138691 142961 147233 151507 155783 160061 164341 168623 172907 177193 181481 185771 190063 194357 19865...
output:
1.2242e+07 1.22471e+07 1.22522e+07 1.22574e+07 1.22625e+07 1.22676e+07 1.22727e+07 1.22778e+07 1.22829e+07 1.2288e+07
result:
wrong answer 1st lines differ - expected: '12242000 12247120.5 12252240 1... 12277822.5 12282936 12288048.5', found: '1.2242e+07 1.22471e+07 1.22522...778e+07 1.22829e+07 1.2288e+07 '
Subtask #2:
score: 0
Wrong Answer
Test #9:
score: 14
Accepted
time: 179ms
memory: 11296kb
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:
167 167 167 167 167 167 167 167 167 167
result:
ok single line: '167 167 167 167 167 167 167 167 167 167 '
Test #10:
score: 0
Wrong Answer
time: 148ms
memory: 8776kb
input:
200000 10 6850386 2684591 6734660 10784731 14834804 18884879 22934956 26985035 31035116 35085199 39135284 43185371 47235460 51285551 55335644 59385739 63435836 67485935 71536036 75586139 79636244 83686351 87736460 91786571 95836684 99886799 103936916 107987035 112037156 116087279 120137404 124187531...
output:
6.84539e+11 6.84542e+11 6.84545e+11 6.84549e+11 6.84552e+11 6.84556e+11 6.84559e+11 6.84563e+11 6.84566e+11 6.84569e+11
result:
wrong answer 1st lines differ - expected: '684538602443.5 684542027636.5 ...5 684566003987.5 684569429180.5', found: '6.84539e+11 6.84542e+11 6.8454...63e+11 6.84566e+11 6.84569e+11 '
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 ...