QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#449633 | #8597. Запити красот пiдмасивiв | arbuzick# | 0 | 1ms | 3644kb | C++20 | 971b | 2024-06-21 15:33:30 | 2024-06-21 15:33:30 |
answer
#include <bits/extc++.h>
using namespace std;
void solve() {
int n, q;
cin >> n >> q;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
vector<long long> pr_sum(n + 1);
for (int i = 0; i < n; ++i) {
pr_sum[i + 1] = pr_sum[i] + a[i];
}
while (q--) {
int tp;
cin >> tp;
if (tp == 1) {
int l, r;
cin >> l >> r;
l--;
long long ans = abs(pr_sum[r] - pr_sum[l]);
for (int len = 1; len < r - l; ++len) {
ans = max(ans, min(abs(pr_sum[l + len] - pr_sum[l]), abs(pr_sum[r] - pr_sum[l + len])));
}
cout << ans << '\n';
} else {
assert(false);
}
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
详细
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
1000000 1000000 548734664 631285694 511074814 185066089 177199147 524740185 143108778 954318193 103939390 194933972 126964310 977448144 188825490 775722231 460775045 254691982 436971964 566341931 148211711 74910105 923734998 440021758 474275150 717904448 680353276 612974499 712145218 300908726 34722...
output:
251801387395338 230985543990378 233364582761908 165509624203582 383254838720986 448483728625094 365779189638223 259921744673457 396032911262151 463175787332481 396490494773605 379294045009719 380905359946099 248640668979163 372751657582612 250611799614193 382671202614963 249747705028859 377678676465...
result:
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 1ms
memory: 3644kb
input:
1000 1000 -873807720 -737050877 797489760 406646247 -750849890 -581119106 43724194 -931326234 -9389547 -684003608 -926307185 -502569356 -461635706 -238087464 -83909772 -884633970 46721429 -576741985 -323890970 -855342249 -736506813 336516318 -4075924 -782227362 56799828 290931118 -471600723 81594380...
output:
9772834244 7971661681 7251185652 5902581650 12301584130 9137214347 10770040139 9693548841 12636393268 9951777555 8590138425 9126178404 8438322412 10469973494 9585010202 12336530829 12305905331 12818655084 9576894451 9228532410 10060968297 12060843219 8619457836 8862797014 12336530829 6408306273 9621...
result:
wrong answer 44th numbers differ - expected: '5882777912', found: '4307081773'
Subtask #3:
score: 0
Time Limit Exceeded
Test #14:
score: 0
Time Limit Exceeded
input:
200000 200000 580139218 -783262026 565291185 -701435432 -591602198 -342573855 -900284959 -10919966 -682899137 -282058183 963121871 491072571 691886927 761414760 -828585515 888361166 -790814084 145385324 214735368 388759807 -80339362 -975535748 522135695 301673442 36714481 785639770 319723485 1098009...
output:
351460487491 210343422436 312498498649 203192986383 287815765786 245818714404 213968420688 159327542896 169009698075 212975612931 197610853645 255310400798 318802499824 292657635865 313528174745 321957839407 262317902055 187559666100 220264896012 221468083688 294234309666 310907237863 189575747002 1...
result:
Subtask #4:
score: 0
Time Limit Exceeded
Test #21:
score: 0
Time Limit Exceeded
input:
200000 200000 128744308 920701830 -482412021 59142239 721167306 -622861403 165749748 -449445968 -760679479 -207234657 171482190 -239316743 75518499 -717652242 502074875 -731242646 -183939818 -625333917 -53052313 185734819 -780000096 -563390882 -690210905 596581513 764466021 776717157 -38544163 -7898...
output:
128744308 1049446138 567034117 626176356 1347343662 724482259 890232007 906557623 1347343662 1347343662 1347343662 1347343662 1347343662 1347343662 1347343662 1466264164 1650203982 2275537899 2328590212 2142855393 2922855489 3486246371 4176457276 3579875763 2815409742 2137764691 2099220528 286704480...
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #28:
score: 0
Time Limit Exceeded
input:
200000 200000 3 -5 -3 3 3 -5 7 -2 2 -4 -4 9 0 -4 -2 2 -5 7 -2 3 -8 1 6 -7 9 -3 -2 4 -2 -2 3 -2 1 0 -3 6 0 -6 -2 6 -5 6 -4 3 2 -4 5 -2 -8 1 1 2 1 -3 3 5 -9 1 3 -2 0 1 -2 1 2 5 -1 -4 -1 -3 7 -7 7 1 -6 7 -1 -5 1 4 -7 6 -3 -4 -1 4 1 5 -7 -3 9 1 -6 2 -3 1 6 -1 -1 1 -1 -5 -3 9 -5 4 -1 3 -2 -4 -4 8 1 0 -9 ...
output:
9 7 8 6 8 4 5 7 9 9 5 9 6 6 9 4 8 9 8 5 6 6 5 7 6 4 5 7 8 5 6 7 5 5 7 7 5 9 7 5 9 5 8 10 5 7 6 8 5 5 6 7 7 6 6 8 4 6 9 4 6 5 6 5 8 6 6 5 5 9 8 5 7 6 4 5 6 6 5 7 4 5 4 4 6 7 9 9 8 9 7 6 5 9 9 7 8 5 9 4 7 8 9 7 8 9 8 8 5 6 8 8 4 6 5 6 6 5 9 6 6 8 9 5 8 6 5 5 7 5 10 7 5 5 6 8 6 8 6 5 6 8 6 5 10 8 7 6 6...
result:
Subtask #6:
score: 0
Skipped
Dependency #1:
0%
Subtask #7:
score: 0
Skipped
Dependency #6:
0%
Subtask #8:
score: 0
Skipped
Dependency #6:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
0%