QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789298#5549. Game ShowFireball0424#AC ✓64ms12600kbC++142.0kb2024-11-27 19:49:242024-11-27 19:49:29

Judging History

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

  • [2024-11-27 19:49:29]
  • 评测
  • 测评结果:AC
  • 用时:64ms
  • 内存:12600kb
  • [2024-11-27 19:49:24]
  • 提交

answer

// #pragma GCC optimizer("Ofast")
// #pragma GCC target("avx2")
#include <bits/stdc++.h>
#define int long long 
#define ld long double
#define ull unsigned long long 
#define fr first
#define fi first
#define sc second
#define se second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
//#define sz(x) (int)x.size()
using namespace std;

#ifndef fireball
#define tofu ios::sync_with_stdio(0); cin.tie(0);
#else
#define tofu freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif 

void db() {cout << '\n';}
template <typename T, typename ...U> void db(T a, U ...b) {cout << a << ' ', db(b...);}

signed main(){
    tofu;
    int n, q; cin >> n >> q;
    vector<int> l(n + 1, 0), r(n + 1, 0);
    for(int i = 1; i <= n; ++i) cin >> r[i];
    for(int i = 1; i <= n; ++i){
        if(i < n) cin >> l[i + 1];
        else cin >> l[1];
    }

    int yes = 0, sum_l = 0, sum_r = 0;
    for(int i = 1; i <= n; ++i){
        int x;
        if(i < n) x = r[i] + l[i + 1];
        else x = r[i] + l[1];
        if(x < 0) yes = 1;

        sum_l += l[i];
        sum_r += r[i];
    }
    if(sum_l < 0 or sum_r < 0) yes = 1;

    vector<int> pre(2 * n + 1, 0), suf(2 * n + 2, 0);
    for(int i = 1; i <= 2 * n; ++i){
        if(i <= n) pre[i] = pre[i - 1] + r[i];
        else pre[i] = pre[i - 1] + r[i - n];
    }
    for(int i = 2 * n; i > 0; --i){
        if(i > n) suf[i] = suf[i + 1] + l[i - n];
        else suf[i] = suf[i + 1] + l[i];
    }

    // for(int i = 1; i <= 2 * n; ++i) cout << pre[i] << ' ';
    // db();   
    // for(int i = 1; i <= 2 * n; ++i) cout << suf[i] << ' ';
    // db();


    while(q--){
        int st, ed; cin >> st >> ed;
        if(yes){
            db("flawed");
            continue;
        }

        int ans;
        if(st <= ed){
            ans = min(pre[ed - 1] - pre[st - 1], suf[ed + 1] - suf[st + n + 1]);
        }
        else{
            ans = min(pre[ed + n - 1] - pre[st - 1], suf[ed + 1] - suf[st + 1]);
        }
        db(ans);

    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3524kb

input:

4 4
2 3 -4 3
1 2 7 -1
1 3
3 1
1 4
1 1

output:

5 
-1 
-1 
0 

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

4 3
1 2 -3 4
4 -3 2 1
1 1
2 4
3 1

output:

flawed 
flawed 
flawed 

result:

ok 3 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3480kb

input:

6 2
-6 8 -3 5 -9 4
9 -2 8 -4 12 -1
2 6
3 3

output:

flawed 
flawed 

result:

ok 2 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

3 1
1 2 3
2 3 1
3 3

output:

0 

result:

ok single line: '0 '

Test #5:

score: 0
Accepted
time: 2ms
memory: 3756kb

input:

119 14161
-471334480 -303286501 -823503521 204458352 428751472 -685555801 -315724979 454499825 326635838 274924560 623877126 -41230889 829726183 -901302108 -414222870 430105197 -163781582 -654097302 -785578511 634678229 -53714045 466578268 -156361557 31276696 778119895 744605022 -686693025 368251457...

output:

flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flaw...

result:

ok 14161 lines

Test #6:

score: 0
Accepted
time: 12ms
memory: 3800kb

input:

310 96100
995988008 -273572056 647506325 206645991 -449149473 -743958256 -263018073 522873394 -995870737 391893724 -602177324 912246319 -671361368 -339118861 787545510 276780215 150123420 -438281015 -486464371 -526419934 457117467 -340697687 -193705644 583522844 -862239080 -783668951 886284879 -2153...

output:

0 
995988008 
722415952 
1369922277 
1576568268 
1127418795 
383460539 
120442466 
643315860 
-352554877 
39338847 
-562838477 
349407842 
-321953526 
-661072387 
126473123 
403253338 
553376758 
115095743 
-371368628 
-897788562 
-440671095 
-781368782 
-975074426 
-391551582 
-1253790662 
-2037459...

result:

ok 96100 lines

Test #7:

score: 0
Accepted
time: 3ms
memory: 3840kb

input:

159 25281
571110069 497946045 215248224 285606755 -114253939 796175515 -214494926 -691740300 -694515306 425784607 -884181443 -417222365 -923910646 913088205 334337646 928400844 604137042 -251172024 -292361941 -243464366 315724262 -281093691 800734894 966549738 -939146974 -612753418 946191607 -701002...

output:

flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flaw...

result:

ok 25281 lines

Test #8:

score: 0
Accepted
time: 18ms
memory: 3504kb

input:

386 148996
-629374153 -930021329 -169749492 77888804 39969974 891272130 -96385962 -76492169 599659860 -779504873 921044785 937376141 597906327 -96821407 631221939 609871141 363156207 -866807335 -188422318 -528059242 964816522 314282210 -604961795 514941685 56630262 -956662135 343379714 218344584 -59...

output:

0 
-629374153 
-1559395482 
-1729144974 
-1651256170 
-1611286196 
-720014066 
-816400028 
-892892197 
-293232337 
-1072737210 
-151692425 
785683716 
1383590043 
1286768636 
1917990575 
2527861716 
2891017923 
2024210588 
1835788270 
1307729028 
2272545550 
2586827760 
1981865965 
2496807650 
25534...

result:

ok 148996 lines

Test #9:

score: 0
Accepted
time: 56ms
memory: 12540kb

input:

200000 200000
542641702 524593830 -670388831 -945604405 -364992596 191170051 -26787814 66913368 -262048292 -713493534 737457155 149980656 479874963 409329298 936423541 -409385368 410613548 -268647340 -209178559 -538810729 -311979646 896593511 -414858308 -508018786 166275960 712369177 113795469 81304...

output:

flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flaw...

result:

ok 200000 lines

Test #10:

score: 0
Accepted
time: 64ms
memory: 12468kb

input:

200000 200000
-859117315 241669988 515635146 -974661709 -565625054 -798417276 -544902983 -211538953 -243302276 336115744 -956543301 662011337 -791751745 318028077 -996636934 872505404 420483514 -375259846 126912462 494420432 523114793 -293956991 -989076221 387126868 -304945172 -581498983 -830472298 ...

output:

253349035948 
311225694871 
61702809599 
505480747159 
318262775201 
328494991458 
416520464677 
243285217797 
224189228033 
279180960020 
312970799627 
347682772871 
362965581804 
203558820062 
373599030300 
431153864045 
264323527787 
176719325017 
329753383539 
585052004456 
451387888964 
4317114...

result:

ok 200000 lines

Test #11:

score: 0
Accepted
time: 30ms
memory: 7772kb

input:

100000 200000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 ...

output:

1000000000 
0 
-1000000000 
-2000000000 
-3000000000 
-4000000000 
-5000000000 
-6000000000 
-7000000000 
-8000000000 
-9000000000 
-10000000000 
-11000000000 
-12000000000 
-13000000000 
-14000000000 
-15000000000 
-16000000000 
-17000000000 
-18000000000 
-19000000000 
-20000000000 
-21000000000 
...

result:

ok 200000 lines

Test #12:

score: 0
Accepted
time: 59ms
memory: 12460kb

input:

200000 200000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 ...

output:

99951000000000 
99954000000000 
99995000000000 
99969000000000 
99994000000000 
99990000000000 
99964000000000 
99973000000000 
99966000000000 
99991000000000 
99990000000000 
99967000000000 
99959000000000 
99986000000000 
99951000000000 
99976000000000 
99972000000000 
99975000000000 
999620000000...

result:

ok 200000 lines

Test #13:

score: 0
Accepted
time: 45ms
memory: 12600kb

input:

200000 200000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 ...

output:

flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flaw...

result:

ok 200000 lines

Test #14:

score: 0
Accepted
time: 58ms
memory: 12600kb

input:

200000 200000
918023196 96461632 869831293 -807407070 556243762 534347218 840800033 -727901758 328367541 -805840542 -728163855 96436945 119365052 -488831892 -82532154 432548795 -98283674 453037664 418102986 460104469 588941197 721711740 -954753749 -35164942 292925043 980999687 369474604 281472856 -8...

output:

-32842628012 
-29198570852 
-19936603864 
-736713879 
-95967703728 
49247141359 
-38610448654 
809185757 
2798124645 
-64300376469 
-51394149939 
127865383356 
-25297949226 
-45162129787 
101758509026 
16613087582 
-293803684 
-40625674519 
-11532555818 
-112383173294 
-10470698318 
-11367861564 
-4...

result:

ok 200000 lines

Test #15:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

3 2
1 2 3
2 3 1
1 2
2 1

output:

1 
2 

result:

ok 2 lines

Test #16:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

3 9
0 0 0
0 0 0
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3

output:

0 
0 
0 
0 
0 
0 
0 
0 
0 

result:

ok 9 lines

Test #17:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

3 9
5 -4 -1
-5 4 1
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3

output:

0 
5 
1 
-5 
0 
-4 
-1 
4 
0 

result:

ok 9 lines

Test #18:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

5 25
1 -3 -5 -7 3
7 10 44 3 5
1 1
1 2
1 3
1 4
1 5
2 1
2 2
2 3
2 4
2 5
3 1
3 2
3 3
3 4
3 5
4 1
4 2
4 3
4 4
4 5
5 1
5 2
5 3
5 4
5 5

output:

flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 

result:

ok 25 lines

Test #19:

score: 0
Accepted
time: 0ms
memory: 3476kb

input:

5 25
6 10 15 -6 -7
-5 -9 -14 6 8
1 1
1 2
1 3
1 4
1 5
2 1
2 2
2 3
2 4
2 5
3 1
3 2
3 3
3 4
3 5
4 1
4 2
4 3
4 4
4 5
5 1
5 2
5 3
5 4
5 5

output:

flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 

result:

ok 25 lines

Test #20:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

5 25
7 12 15 22 33
69 69 -42 69 69
1 1
1 2
1 3
1 4
1 5
2 1
2 2
2 3
2 4
2 5
3 1
3 2
3 3
3 4
3 5
4 1
4 2
4 3
4 4
4 5
5 1
5 2
5 3
5 4
5 5

output:

flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 

result:

ok 25 lines

Test #21:

score: 0
Accepted
time: 7ms
memory: 3796kb

input:

265 70225
185689233 205526741 89766355 247127393 -231236584 -404930790 -886574049 -454687411 583450067 57789843 136089128 851193267 -857927883 296343753 -263516925 914310309 -719298446 957236686 598317128 40954961 -763451153 279842034 889337838 43696656 -170676118 -470888777 548467373 -87699328 1368...

output:

flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flawed 
flaw...

result:

ok 70225 lines

Test #22:

score: 0
Accepted
time: 9ms
memory: 3604kb

input:

334 111556
497576505 360231077 -524385517 591069494 -656293801 7867219 -101416704 -407515227 -391063191 771924531 678378242 -296258873 -524516353 476780676 4778913 110722520 885167206 -596964575 267995391 97038192 734578811 39285651 880419387 -302434682 501529728 399150123 -702341407 935931142 -7362...

output:

0 
497576505 
857807582 
333422065 
924491559 
268197758 
276064977 
174648273 
-232866954 
-623930145 
147994386 
826372628 
530113755 
5597402 
482378078 
487156991 
597879511 
1483046717 
886082142 
1154077533 
1251115725 
1985694536 
2024980187 
2905399574 
2602964892 
3104494620 
3503644743 
28...

result:

ok 111556 lines