QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#887209#10050. Bitaro the Brave 2modwwe31 7ms10760kbC++232.6kb2025-02-07 15:44:062025-02-07 15:44:13

Judging History

This is the latest submission verdict.

  • [2025-02-07 15:44:13]
  • Judged
  • Verdict: 31
  • Time: 7ms
  • Memory: 10760kb
  • [2025-02-07 15:44:06]
  • Submitted

answer

#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int   long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task2 "ftree"
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define mask(k) (1<<k)
#define mp make_pair
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());

int rand(int l,int r)
{
    return uniform_int_distribution<int>(l,r)(rd);
}
inline int scan()
{
    char c = getchar_unlocked();
    int x = 0;
    while (c < '0' || c > '9')
    {
        c = getchar_unlocked();
    }
    while (c >= '0' && c <= '9')
    {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar_unlocked();
    }
    return x;
}
void phongbeo();
const int inf = 1e16;
const ll mod2 = 1e9+7;
const int  mod1 = 998244353;
const ll base=67;
int add(int x,int y)
{
    if(x+y>=mod2) x-=mod2;
    if(x+y<0)x+=mod2;
    return x+y;
}
struct icd
{
    long double a;
    int b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a, b, c, d;
};
struct ie
{
    int a, b, c, d, e;

};
int  n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int  i, s10, s12,k1,k2,k3,s11,lim,w,l,r ;
int kk;
int el = 19;
main()
{
    if(fopen(task2".inp","r"))
    {
        fin(task2);
        fou(task2);
    }
    if(fopen(task".inp","r"))
    {
        fin(task);
        fou(task);
    }
    NHP
    /// cin>>s1;
    //modwwe
    phongbeo(),down
    // checktime
}
int a[200007];
int b[200007];
int t[200007];
int suff[200007];
int pre[200007];
void phongbeo()
{
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>a[i];
    for(int i=1; i<=n; i++)
        cin>>b[i],b[i]+=b[i-1];
    for(int i=1; i<=n; i++)
    {
        t[i]=a[i]-b[i-1];
    }
    suff[n+1]=-1e12;
    pre[0]=-1e12;
    for(int i=n; i>=1; --i)
        suff[i]=max(suff[i+1],t[i]);
    for(int i=1; i<=n; i++)
        pre[i]=max(pre[i-1],t[i]);
    s4=1e9+1;
    for(int i=1; i<=n; i++)
    {
        s5=max({pre[i-1]-b[n]+b[i-1],suff[i]+b[i-1],0ll});
        s4=min(s4,s5);
    }
    cout<<s4;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 9964kb

input:

2000
10 9 9 9 9 9 10 9 10 10 9 10 9 10 9 9 10 9 9 9 10 9 10 10 9 10 10 9 9 10 9 10 10 10 9 10 10 9 10 9 9 10 10 9 9 9 9 9 9 9 9 10 9 10 10 10 9 10 9 9 10 9 10 10 10 10 10 9 10 10 10 9 9 9 9 10 9 10 9 10 9 10 10 10 10 9 9 10 10 9 9 9 9 10 9 10 10 10 9 9 9 10 9 9 9 9 10 10 10 9 10 10 10 10 9 10 9 10 9...

output:

9

result:

ok single line: '9'

Test #2:

score: 10
Accepted
time: 2ms
memory: 9836kb

input:

2000
9 9 10 9 10 9 10 9 9 9 10 10 9 10 10 9 9 10 9 10 10 9 10 9 9 9 10 10 10 10 9 10 9 10 9 9 10 9 9 9 9 9 10 10 9 9 9 10 9 9 10 9 9 9 9 10 10 9 10 10 10 10 10 9 9 10 10 9 9 9 9 10 10 10 9 10 9 9 10 9 9 10 9 9 9 10 9 10 10 9 9 10 10 9 9 9 10 9 10 9 10 9 9 10 9 9 9 10 9 10 9 9 9 9 10 9 9 10 10 9 10 1...

output:

9

result:

ok single line: '9'

Test #3:

score: 10
Accepted
time: 1ms
memory: 9964kb

input:

2000
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...

output:

0

result:

ok single line: '0'

Test #4:

score: 10
Accepted
time: 2ms
memory: 9832kb

input:

2000
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...

output:

0

result:

ok single line: '0'

Test #5:

score: 10
Accepted
time: 0ms
memory: 9832kb

input:

2000
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...

output:

0

result:

ok single line: '0'

Test #6:

score: 10
Accepted
time: 1ms
memory: 9840kb

input:

2000
8 6 6 8 8 9 7 6 8 7 10 8 6 8 9 8 10 9 10 10 6 6 10 9 7 8 9 9 7 9 6 10 6 8 6 9 8 10 10 8 9 6 10 10 7 9 10 7 7 10 9 10 10 9 9 10 7 9 8 7 7 9 6 6 9 9 9 6 7 8 8 8 10 8 7 9 10 7 9 6 8 6 6 6 10 10 8 8 9 8 7 9 8 8 10 9 7 6 7 7 7 6 8 10 6 8 9 9 10 9 10 10 7 10 9 7 9 9 6 9 10 6 7 7 10 9 8 7 9 8 8 6 9 10...

output:

10

result:

ok single line: '10'

Test #7:

score: 10
Accepted
time: 1ms
memory: 9964kb

input:

2000
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...

output:

8

result:

ok single line: '8'

Test #8:

score: 10
Accepted
time: 1ms
memory: 9964kb

input:

2000
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...

output:

10

result:

ok single line: '10'

Test #9:

score: 10
Accepted
time: 0ms
memory: 9820kb

input:

2000
21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 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...

output:

8

result:

ok single line: '8'

Test #10:

score: 10
Accepted
time: 0ms
memory: 7936kb

input:

2000
21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 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...

output:

9

result:

ok single line: '9'

Subtask #2:

score: 21
Accepted

Test #11:

score: 21
Accepted
time: 0ms
memory: 9836kb

input:

2000
100000000 100000001 100000002 100000003 100000004 100000005 100000006 100000007 100000008 100000009 100000010 100000011 100000012 100000013 100000014 100000015 100000016 100000017 100000018 100000019 100000020 100000021 100000022 100000023 100000024 100000025 100000026 100000027 100000028 10000...

output:

99999489

result:

ok single line: '99999489'

Test #12:

score: 21
Accepted
time: 0ms
memory: 9840kb

input:

2000
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...

output:

1000000000

result:

ok single line: '1000000000'

Test #13:

score: 21
Accepted
time: 0ms
memory: 9836kb

input:

2000
100000000 99999999 99999998 99999997 99999996 99999995 99999994 99999993 99999992 99999991 99999990 99999989 99999988 99999987 99999986 99999985 99999984 99999983 99999982 99999981 99999980 99999979 99999978 99999977 99999976 99999975 99999974 99999973 99999972 99999971 99999970 99999969 999999...

output:

99999017

result:

ok single line: '99999017'

Test #14:

score: 21
Accepted
time: 0ms
memory: 9840kb

input:

2000
99999990 99999990 99999993 99999995 99999994 99999999 99999999 99999993 99999992 99999993 99999996 99999995 99999998 99999999 99999995 99999997 99999991 99999991 99999991 99999999 99999997 99999995 99999992 99999992 99999994 99999997 99999990 99999998 99999990 99999992 99999999 99999995 9999999...

output:

99999995

result:

ok single line: '99999995'

Test #15:

score: 21
Accepted
time: 0ms
memory: 7940kb

input:

2000
99999997 99999998 99999994 99999999 99999996 99999994 99999997 99999997 99999993 99999998 99999997 99999998 99999999 99999991 99999999 99999992 99999995 99999994 99999992 99999991 99999991 99999995 99999997 99999997 99999990 99999999 99999998 99999998 99999998 99999991 99999997 99999994 9999999...

output:

99999996

result:

ok single line: '99999996'

Test #16:

score: 21
Accepted
time: 1ms
memory: 9968kb

input:

2000
99999996 99999998 99999997 99999993 99999997 99999998 99999995 99999990 99999995 99999999 99999994 99999997 99999994 99999997 99999991 99999998 99999996 99999992 99999997 99999997 99999992 99999990 99999999 99999997 99999990 99999998 99999998 99999999 99999997 99999990 99999992 99999999 9999999...

output:

99999996

result:

ok single line: '99999996'

Test #17:

score: 21
Accepted
time: 0ms
memory: 9908kb

input:

2000
500000000 595954395 500000000 719922556 500000000 673855701 500000000 524733105 500000000 569117483 500000000 645988962 500000000 618369893 500000000 603500273 500000000 703349061 500000000 744916082 500000000 640655652 500000000 523816441 500000000 673995695 500000000 569697107 500000000 71052...

output:

740407931

result:

ok single line: '740407931'

Test #18:

score: 21
Accepted
time: 1ms
memory: 9836kb

input:

2000
500000000 521755178 456489644 500000000 546667566 406664868 500000000 530279196 439441608 500000000 581555724 336888552 500000000 652694037 194611926 500000000 582467170 335065660 500000000 504346000 491308000 500000000 629620007 240759986 500000000 642779991 214440018 500000000 646764177 20647...

output:

661631870

result:

ok single line: '661631870'

Test #19:

score: 21
Accepted
time: 0ms
memory: 9984kb

input:

2000
500000000 552697382 605394764 341907854 500000000 509601020 519202040 471196940 500000000 614172225 728344450 157483325 500000000 610176729 720353458 169469813 500000000 605313640 710627280 184059080 500000000 605975345 711950690 182073965 500000000 543566392 587132784 369300824 500000000 55783...

output:

742359908

result:

ok single line: '742359908'

Test #20:

score: 21
Accepted
time: 1ms
memory: 9856kb

input:

2000
500000000 541907823 583815646 374276531 332368708 500000000 570171481 640342962 289485557 219314076 500000000 592827464 685654928 221517608 128690144 500000000 557436775 614873550 327689675 270252900 500000000 556968155 613936310 329095535 272127380 500000000 583513888 667027776 249458336 16594...

output:

686324284

result:

ok single line: '686324284'

Test #21:

score: 21
Accepted
time: 0ms
memory: 7940kb

input:

2000
500000000 536137908 572275816 608413724 644551632 680689540 283172552 247034644 210896736 174758828 500000000 540969022 581938044 622907066 663876088 704845110 254185868 213216846 172247824 131278802 500000000 510166059 520332118 530498177 540664236 550830295 439003646 428837587 418671528 40850...

output:

737919838

result:

ok single line: '737919838'

Test #22:

score: 21
Accepted
time: 0ms
memory: 9964kb

input:

2000
500000000 500926607 501853214 502779821 503706428 504633035 505559642 506486249 507412856 508339463 509266070 510192677 511119284 512045891 512972498 513899105 514825712 515752319 516678926 517605533 518532140 519458747 520385354 521311961 522238568 523165175 524091782 525018389 525944996 52687...

output:

727326597

result:

ok single line: '727326597'

Test #23:

score: 21
Accepted
time: 1ms
memory: 9836kb

input:

2000
500000 500484 500968 498548 500000 500633 501266 498101 500000 500606 501212 498182 500000 500597 501194 498209 500000 500585 501170 498245 500000 500576 501152 498272 500000 500575 501150 498275 500000 500360 500720 498920 500000 500380 500760 498860 500000 500412 500824 498764 500000 500693 5...

output:

1992

result:

ok single line: '1992'

Test #24:

score: 21
Accepted
time: 0ms
memory: 9836kb

input:

2000
500000 500606 501212 498182 500000 500374 500748 498878 500000 500348 500696 498956 500000 500391 500782 498827 500000 500507 501014 498479 500000 500337 500674 498989 500000 500638 501276 498086 500000 500341 500682 498977 500000 500664 501328 498008 500000 500664 501328 498008 500000 500334 5...

output:

1977

result:

ok single line: '1977'

Test #25:

score: 21
Accepted
time: 0ms
memory: 9832kb

input:

2000
500000 500470 500940 498590 498120 500000 500639 501278 498083 497444 500000 500622 501244 498134 497512 500000 500393 500786 498821 498428 500000 500511 501022 498467 497956 500000 500381 500762 498857 498476 500000 500624 501248 498128 497504 500000 500420 500840 498740 498320 500000 500317 5...

output:

1958

result:

ok single line: '1958'

Test #26:

score: 21
Accepted
time: 0ms
memory: 7808kb

input:

2000
500000 500418 500836 501254 501672 502090 497492 497074 496656 496238 500000 500430 500860 501290 501720 502150 497420 496990 496560 496130 500000 500536 501072 501608 502144 502680 496784 496248 495712 495176 500000 500345 500690 501035 501380 501725 497930 497585 497240 496895 500000 500382 5...

output:

2014

result:

ok single line: '2014'

Subtask #3:

score: 0
Wrong Answer

Test #27:

score: 0
Wrong Answer
time: 6ms
memory: 10760kb

input:

500000
3 4 10 8 4 3 8 10 1 7 2 5 5 4 8 6 5 9 1 6 5 7 2 9 7 1 6 7 9 6 5 3 2 5 9 8 5 9 7 6 3 8 6 4 7 4 2 1 3 7 9 5 2 10 4 6 3 5 7 7 2 1 3 1 6 7 5 6 8 7 10 6 10 8 5 9 3 4 5 7 9 2 4 2 10 2 5 1 8 1 5 1 5 6 10 7 6 4 6 3 5 9 7 1 7 10 8 8 7 2 3 4 10 3 8 4 1 6 6 1 1 7 5 9 8 1 6 2 2 5 1 1 3 3 1 3 4 1 9 1 5 6 ...

output:

3

result:

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

Subtask #4:

score: 0
Runtime Error

Test #42:

score: 0
Runtime Error

input:

500000
500000 500064 500128 500192 500256 500320 500384 500448 500512 500576 500640 500704 500768 500832 500896 500960 501024 501088 501152 501216 501280 501344 501408 501472 501536 501600 501664 501728 501792 501856 501920 501984 502048 502112 502176 502240 502304 502368 502432 502496 502560 502624...

output:


result:


Subtask #5:

score: 0
Wrong Answer

Test #56:

score: 0
Wrong Answer
time: 7ms
memory: 8092kb

input:

500000
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...

output:

1000000001

result:

wrong answer 1st lines differ - expected: '1000000000', found: '1000000001'