QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#789829 | #1397. Growing Vegetables is Fun | modwwe | 100 ✓ | 65ms | 16428kb | C++23 | 2.7kb | 2024-11-27 22:09:17 | 2024-11-27 22:09:18 |
Judging History
answer
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC optimize("conserve-stack")
#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 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
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 = 1e9;
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,t,lim,w,l,r ;
int kk;
int el = 19;
main()
{
if(fopen(task".inp","r"))
{
fin(task);
fou(task);
}
NHP
/// cin>>s1;
// modwwe
phongbeo();
// checktime
}
int a[300001];
vector<int> v;
int lef[300001];
int rig[300001];
struct fen
{
int bit[300001];
void upd(int x)
{
for(x; x; x-=x&-x)
bit[x]++;
}
int get(int x)
{
int s=0;
for(x; x<=n; x+=x&-x)
s+=bit[x];
return s;
}
} fen;
void phongbeo()
{
cin>>n;
for(int i=1; i<=n; i++)
cin>>a[i],v.pb(a[i]);
sort(v.begin(),v.end());
v.erase(unique(v.begin(),v.end()),v.end());
for(int i=1; i<=n; i++)
a[i]=lower_bound(v.begin(),v.end(),a[i])-v.begin()+1;
for(int i=1; i<=n; i++)
{
lef[i]=fen.get(a[i]+1);
fen.upd(a[i]);
}
for(int i=1; i<=n; i++)
fen.bit[i]=0;
for(int i=n; i>=1; --i)
{
rig[i]=fen.get(a[i]+1);
fen.upd(a[i]);
}
s4=0;
for(int i=1; i<=n; i++){
s4=s4+min(lef[i],rig[i]);}
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: 9792kb
input:
5 2 8 3 5 4
output:
1
result:
ok single line: '1'
Test #2:
score: 10
Accepted
time: 0ms
memory: 9832kb
input:
8 8 5 1 4 15 51 11 28
output:
6
result:
ok single line: '6'
Test #3:
score: 10
Accepted
time: 1ms
memory: 9728kb
input:
8 100 200 50 20 200 100 800 999
output:
7
result:
ok single line: '7'
Test #4:
score: 10
Accepted
time: 1ms
memory: 9744kb
input:
7 1 4 7 7 7 4 1
output:
0
result:
ok single line: '0'
Test #5:
score: 10
Accepted
time: 0ms
memory: 9780kb
input:
8 99 99 99 99 99 99 99 99
output:
0
result:
ok single line: '0'
Test #6:
score: 10
Accepted
time: 0ms
memory: 9780kb
input:
8 96000000 84000000 72000000 60000000 48000000 36000000 24000000 12000000
output:
0
result:
ok single line: '0'
Test #7:
score: 10
Accepted
time: 1ms
memory: 9856kb
input:
8 601322016 20074950 155956323 324319474 941696870 997306693 403450092 502381552
output:
4
result:
ok single line: '4'
Test #8:
score: 10
Accepted
time: 1ms
memory: 9696kb
input:
8 400000000 400000000 263539424 400000000 400000000 458424839 414860359 502762549
output:
3
result:
ok single line: '3'
Test #9:
score: 10
Accepted
time: 1ms
memory: 9780kb
input:
8 90000000 70000000 50000000 10000000 30000000 50000000 70000000 90000000
output:
12
result:
ok single line: '12'
Test #10:
score: 10
Accepted
time: 1ms
memory: 9792kb
input:
7 307518180 383138743 400195098 300476710 2014 2014 408432459
output:
3
result:
ok single line: '3'
Subtask #2:
score: 20
Accepted
Dependency #1:
100%
Accepted
Test #11:
score: 20
Accepted
time: 1ms
memory: 9788kb
input:
12 20 80 30 55 30 80 90 10 30 70 85 90
output:
14
result:
ok single line: '14'
Test #12:
score: 20
Accepted
time: 1ms
memory: 9852kb
input:
14 10 30 30 80 200 400 400 150 80 30 30 30 10 5
output:
0
result:
ok single line: '0'
Test #13:
score: 20
Accepted
time: 1ms
memory: 9764kb
input:
11 100000000 200000000 300000000 400000000 500000000 600000000 700000000 800000000 900000000 900000000 1000000000
output:
0
result:
ok single line: '0'
Test #14:
score: 20
Accepted
time: 1ms
memory: 9704kb
input:
16 38020 28510 59109 60500 10002 108 22450 108 51002 52002 51890 22450 25202 108 29592 60500
output:
32
result:
ok single line: '32'
Test #15:
score: 20
Accepted
time: 0ms
memory: 9780kb
input:
16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
output:
0
result:
ok single line: '0'
Test #16:
score: 20
Accepted
time: 0ms
memory: 9836kb
input:
15 107286470 941389353 874067939 6662747 117798001 16030521 552757157 979431792 529843078 75288560 434084836 612367732 554396938 550271904 838855249
output:
28
result:
ok single line: '28'
Test #17:
score: 20
Accepted
time: 1ms
memory: 9728kb
input:
16 900000 800000 500000 200000 100000 200000 300000 350000 400000 450000 500000 600000 700000 800000 900000 950000
output:
32
result:
ok single line: '32'
Test #18:
score: 20
Accepted
time: 1ms
memory: 9776kb
input:
15 900000000 742765535 900000000 900000000 748159432 900000000 794026130 900000000 900000000 900000000 756475608 724054692 702828667 900000000 900000000
output:
14
result:
ok single line: '14'
Test #19:
score: 20
Accepted
time: 0ms
memory: 9764kb
input:
16 33349 34423 32907 34508 34793 31811 32189 31304 30367 34379 34880 30611 32485 31519 33826 33864
output:
35
result:
ok single line: '35'
Test #20:
score: 20
Accepted
time: 1ms
memory: 9772kb
input:
16 101164824 178805848 143926182 112256661 107521495 300000000 117240323 195257629 173688529 130829754 176973662 300000000 120285783 179225073 300000000 147582471
output:
25
result:
ok single line: '25'
Subtask #3:
score: 15
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #21:
score: 15
Accepted
time: 1ms
memory: 9740kb
input:
300 905972146 255058605 114356099 848257125 17356212 44031328 549347853 569474479 929925360 240283829 631232520 517625830 60915700 859666464 380617964 817506341 322274449 430302558 923936575 61956725 291315270 968447034 574299484 902436043 127263796 213019116 375236935 84073013 404288886 259876265 9...
output:
11395
result:
ok single line: '11395'
Test #22:
score: 15
Accepted
time: 1ms
memory: 9756kb
input:
1500 79946 79474 79675 79660 79518 79493 79470 79409 79376 79366 79353 79227 79218 79214 79023 79012 78826 78822 78603 78402 78378 78308 78238 78193 78048 78030 78004 77942 77861 77782 77714 77581 77571 77498 77448 77381 77256 77197 77091 77066 76991 76988 76821 76541 76445 76334 76237 76201 76165 7...
output:
454508
result:
ok single line: '454508'
Test #23:
score: 15
Accepted
time: 1ms
memory: 9832kb
input:
2000 2696004 2246305 3270781 2511502 2690816 3485259 2625527 2220653 2166454 3349565 2406002 2337076 1836814 3192506 2359528 3102772 1877092 2600732 3337548 2715324 2769839 3063551 2014320 3336485 2209479 2671488 2158795 3259096 2716045 1926281 2247626 2611692 3487745 3310276 2680516 3371174 2945488...
output:
490787
result:
ok single line: '490787'
Test #24:
score: 15
Accepted
time: 0ms
memory: 9896kb
input:
3500 820954323 816626000 805518484 863139953 812584408 815507238 842079239 839884436 833205942 819771996 826927399 833611737 828203073 897181374 817424064 874054999 802179258 892574766 863865111 875177500 800151880 813633968 832334997 891416716 817697463 874315453 842852532 861541431 897557884 82975...
output:
1522670
result:
ok single line: '1522670'
Test #25:
score: 15
Accepted
time: 0ms
memory: 9880kb
input:
5000 899883354 899866752 899791077 899055543 898862130 898196478 897414043 897156002 896400041 895392879 895295234 894112179 893293478 892863147 892636199 892546061 892435163 892425150 892220215 891927209 890910281 889607840 888212207 888080092 888027513 886381802 886087825 886041891 886015635 88594...
output:
6202441
result:
ok single line: '6202441'
Test #26:
score: 15
Accepted
time: 1ms
memory: 9928kb
input:
5000 2 2 1 2 2 1 2 2 1 2 2 2 2 1 1 1 1 2 1 2 1 2 1 2 1 2 2 2 2 1 2 2 2 2 2 2 1 1 2 1 2 1 2 1 2 1 2 2 2 2 2 2 1 2 2 1 2 1 2 2 1 1 1 1 1 1 2 1 1 2 2 2 2 2 2 2 1 2 1 1 2 2 1 1 1 1 2 2 1 1 2 1 1 2 1 2 2 2 2 2 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 2 2 1 2 2 1 1 1 2 2 2 2 1 2 2 1 2 2 2 2 1 2 1 1 1 2 2 1 1 1 2 1...
output:
1571267
result:
ok single line: '1571267'
Test #27:
score: 15
Accepted
time: 2ms
memory: 11968kb
input:
4800 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 100000000 10000...
output:
58685
result:
ok single line: '58685'
Test #28:
score: 15
Accepted
time: 2ms
memory: 9948kb
input:
5000 99990847 99958911 99951484 99884752 99873039 99855557 99749245 99734193 99702560 99683715 99670572 79478775 99653650 99652237 99607302 99331989 99196569 99060089 98948431 98939155 98923440 15980173 98892981 98849699 98842397 98836510 98768293 98693798 98665147 98638832 98616304 98604066 9855948...
output:
4508957
result:
ok single line: '4508957'
Test #29:
score: 15
Accepted
time: 2ms
memory: 9940kb
input:
5000 16272 17913 14296 10863 19061 15249 12924 15376 10828 17939 12123 18129 10486 10238 18400 14442 17154 11854 19058 12259 15454 13778 10032 16199 15615 13367 10681 10898 15069 19832 17077 14272 14474 14274 17163 18446 12758 10527 18915 13616 11497 12425 17612 15455 19302 16494 17472 16536 18583 1...
output:
3176793
result:
ok single line: '3176793'
Test #30:
score: 15
Accepted
time: 2ms
memory: 9944kb
input:
5000 401006871 77690818 400222 599959 913936 1218098 1527689 1531213 1707469 1988567 2065256 2377143 2850070 2911949 3185728 3245754 3287852 3357279 3414479 3446594 3804615 3983716 4198690 4219752 4339147 4465441 4472903 4736039 4803482 4818932 5087757 5303282 5510223 5593786 5612238 5652557 5702317...
output:
41132
result:
ok single line: '41132'
Subtask #4:
score: 55
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #31:
score: 55
Accepted
time: 11ms
memory: 12420kb
input:
60000 327 323 435 484 367 470 440 401 419 316 463 376 373 390 313 456 449 484 491 320 459 400 344 479 368 374 479 500 366 407 453 384 409 418 376 367 483 455 399 432 454 492 417 439 336 467 305 497 395 432 454 440 442 303 380 371 352 451 336 386 329 361 360 428 340 389 360 333 311 470 384 451 434 45...
output:
445274476
result:
ok single line: '445274476'
Test #32:
score: 55
Accepted
time: 28ms
memory: 13172kb
input:
100000 598913959 591914160 544100470 634333723 748957543 551549197 791035144 607626613 681383219 724006282 790999360 498465770 749167407 620657762 827094307 501105011 531706320 379798780 490328278 813813635 638471421 774787849 607804324 515167187 514811629 650078763 562578962 708153601 497099747 486...
output:
1246845047
result:
ok single line: '1246845047'
Test #33:
score: 55
Accepted
time: 35ms
memory: 12016kb
input:
150000 3107566 3841671 4968931 2341054 2718319 4685332 4687412 3673583 1886927 4743550 1270413 3544860 1545930 1894496 4404197 2015505 1234567 2276445 1324101 3402848 1634732 4628874 1030695 4246668 2043338 2195068 3371824 2290313 2282494 4738586 2073865 4270508 4248990 2739682 1234567 3356981 12345...
output:
2768560877
result:
ok single line: '2768560877'
Test #34:
score: 55
Accepted
time: 54ms
memory: 13156kb
input:
200000 305458949 208616035 309366541 909898736 232452203 597576466 102969140 960207698 728809280 374455922 810908010 625334706 377057501 100000000 519630205 350156994 619746942 124424525 353148832 162419588 630420232 100000000 100000000 100000000 107899485 527488355 623165933 790165401 100000000 100...
output:
4908376472
result:
ok single line: '4908376472'
Test #35:
score: 55
Accepted
time: 23ms
memory: 13272kb
input:
200000 999999962 999999900 999999514 999999496 999999443 999999350 999999111 999998987 999998737 999998722 999998542 999998426 999998333 999998280 999998239 999997963 999997798 999997773 999997666 999997582 999997570 999997356 999997334 999997296 999997235 999997219 999997179 999996941 999996809 999...
output:
0
result:
ok single line: '0'
Test #36:
score: 55
Accepted
time: 16ms
memory: 11104kb
input:
100000 999988873 999985523 999971843 999971294 999968067 999967321 999963976 999953616 140127673 999943361 999936863 999934484 999923485 999912201 999907041 999892489 999885889 999869798 999859543 999855308 999838204 999808280 999801949 999781044 999749049 999725527 999712244 999704728 999691316 999...
output:
1512301800
result:
ok single line: '1512301800'
Test #37:
score: 55
Accepted
time: 25ms
memory: 14892kb
input:
300000 8 8 7 7 8 9 9 7 7 9 7 9 9 7 8 7 7 8 8 9 7 9 9 8 8 9 8 7 8 8 7 8 8 9 7 8 8 9 8 7 8 7 7 8 7 8 8 8 9 9 8 9 7 7 8 7 9 9 7 9 9 8 8 7 9 9 9 9 7 8 7 7 8 8 9 8 7 9 9 7 7 9 7 8 9 8 9 9 7 9 7 9 7 8 8 8 8 9 7 8 9 8 8 7 7 9 8 7 9 8 7 9 9 8 7 8 7 8 9 8 8 8 7 7 7 7 9 7 9 7 8 9 7 7 7 8 7 8 9 7 7 7 8 8 8 7 7...
output:
7490078769
result:
ok single line: '7490078769'
Test #38:
score: 55
Accepted
time: 65ms
memory: 16428kb
input:
300000 999986937 999979173 999976948 999976149 999971258 999968909 999968865 999960077 999933763 999930113 999922546 999921628 999914084 999907460 999903496 999898433 999891622 999889880 999888993 999888552 999882379 999881735 999877822 999877756 999866351 999865179 999855076 999852978 999847696 999...
output:
22467143769
result:
ok single line: '22467143769'
Test #39:
score: 55
Accepted
time: 60ms
memory: 15848kb
input:
300000 987654321 946288524 987654321 987654321 275399914 883210294 987654321 987654321 107623361 384074109 536034615 877069300 987654321 987654321 987654321 87485338 987654321 987654321 987654321 982892990 987654321 987654321 987654321 339084407 987654321 987654321 71727362 858369953 987654321 37948...
output:
8425332391
result:
ok single line: '8425332391'
Test #40:
score: 55
Accepted
time: 62ms
memory: 15004kb
input:
300000 499999592 499993548 637424993 499983905 499981815 421439860 331371623 499968691 499963181 499960396 499960291 503510458 656004049 499948299 499948015 427044059 499944663 499943692 499942472 499938448 499933044 499931792 650357387 499927651 499925577 499902390 499899835 631575847 499896435 499...
output:
11562834650
result:
ok single line: '11562834650'
Extra Test:
score: 0
Extra Test Passed