QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#932969#10210. Misunderstood … MissingN_z_AC ✓103ms19072kbC++236.9kb2025-03-13 10:05:082025-03-13 10:05:08

Judging History

This is the latest submission verdict.

  • [2025-03-13 10:05:08]
  • Judged
  • Verdict: AC
  • Time: 103ms
  • Memory: 19072kb
  • [2025-03-13 10:05:08]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
struct time_helper{
#ifdef LOCAL
clock_t time_last;time_helper(){time_last=clock();}void test(){auto time_now=clock();std::cerr<<"time:"<<1.*(time_now-time_last)/CLOCKS_PER_SEC<<";all_time:"<<1.*time_now/CLOCKS_PER_SEC<<std::endl;time_last=time_now;}~time_helper(){test();}
#else
void test(){}
#endif
}time_helper;
#ifdef LOCAL
#include"dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
namespace Fread{const int SIZE=1<<16;char buf[SIZE],*S,*T;inline char getchar(){if(S==T){T=(S=buf)+fread(buf,1,SIZE,stdin);if(S==T)return'\n';}return *S++;}}namespace Fwrite{const int SIZE=1<<16;char buf[SIZE],*S=buf,*T=buf+SIZE;inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}inline void putchar(char c){*S++=c;if(S==T)flush();}struct NTR{~NTR(){flush();}}ztr;}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
int print_precision=10;bool print_T_endl=1;char print_between=' ';
template<typename T>struct is_char{static constexpr bool value=(std::is_same<T,char>::value||std::is_same<T,signed char>::value||std::is_same<T,unsigned char>::value);};template<typename T>struct is_integral_ex{static constexpr bool value=(std::is_integral<T>::value||std::is_same<T,__int128>::value)&&!is_char<T>::value;};template<typename T>struct is_floating_point_ex{static constexpr bool value=std::is_floating_point<T>::value||std::is_same<T,__float128>::value;};namespace Fastio{struct Reader;struct Writer;template<size_t id>struct read_tuple{template<typename...T>static void read(Reader&stream,std::tuple<T...>&x){read_tuple<id-1>::read(stream,x);stream>>get<id-1>(x);}};template<>struct read_tuple<0>{template<typename...T>static void read([[maybe_unused]]Reader&stream,[[maybe_unused]]std::tuple<T...>&x){}};template<size_t id>struct print_tuple{template<typename...T>static void print(Writer&stream,const std::tuple<T...>&x){print_tuple<id-1>::print(stream,x);putchar(print_between);stream<<get<id-1>(x);}};template<>struct print_tuple<1>{template<typename...T>static void print(Writer&stream,const std::tuple<T...>&x){stream<<get<0>(x);}};template<>struct print_tuple<0>{template<typename...T>static void print([[maybe_unused]]Writer&stream,[[maybe_unused]]const std::tuple<T...>&x){}};
struct Reader{template<typename T>typename std::enable_if_t<std::is_class<T>::value,Reader&>operator>>(T&x){for(auto &y:x)*this>>y;return *this;}template<typename...T>Reader&operator>>(std::tuple<T...>&x){read_tuple<sizeof...(T)>::read(*this,x);return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1;while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}x=0;while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;return *this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1,s=0;x=0;T t=0;while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else return x*=f,*this;while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Reader&>operator>>(T&c){c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();return *this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}template<typename T1,typename T2>Reader&operator>>(std::pair<T1,T2>&x){*this>>x.first>>x.second;return *this;}Reader&operator>>(std::string&str){str.clear();char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';
struct Writer{typedef __int128 mxdouble;template<typename T>typename std::enable_if_t<std::is_class<T>::value,Writer&>operator<<(const T&x){for(auto q:x){*this<<q;if(!is_class<decltype(q)>::value)*this<<print_between;}if(!is_class<typename T::value_type>::value&&print_T_endl)*this<<'\n';return *this;}template<typename...T>Writer&operator<<(const std::tuple<T...>&x){print_tuple<sizeof...(T)>::print(*this,x);if(print_T_endl)*this<<'\n';return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Writer&>operator<<(T x){if(x==0)return putchar('0'),*this;if(x<0)putchar('-'),x=-x;static int sta[45];int top=0;while(x)sta[++top]=x%10,x/=10;while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Writer&>operator<<(T x){if(x<0)putchar('-'),x=-x;x+=pow(10,-print_precision)/2;mxdouble _=x;x-=(T)_;static int sta[45];int top=0;while(_)sta[++top]=_%10,_/=10;if(!top)putchar('0');while(top)putchar(sta[top]+'0'),--top;putchar('.');for(int i=0;i<print_precision;i++)x*=10;_=x;while(_)sta[++top]=_%10,_/=10;for(int i=0;i<print_precision-top;i++)putchar('0');while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Writer&>operator<<(const T&c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return *this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}template<typename T1,typename T2>Writer&operator<<(const std::pair<T1,T2>&x){*this<<x.first<<print_between<<x.second;if(print_T_endl)*this<<'\n';return *this;}Writer&operator<<(const std::string&str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
template<class Fun>class y_combinator_result{Fun fun_;public:template<class T>explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}template<class ...Args>decltype(auto) operator()(Args &&...args){return fun_(std::ref(*this), std::forward<Args>(args)...);}};template<class Fun>decltype(auto) y_combinator(Fun &&fun){return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));}

void init();void solve(int tc);
signed main()
{
    init();int t=1;
    cin>>t;
    for(int tc=1;tc<=t;tc++)solve(tc);
}
void init()
{
}
void solve([[maybe_unused]]int tc)
{
    int n;
    cin>>n;
    vector<tuple<int,int,int>>a(n);
    cin>>a;
    reverse(a.begin(),a.end());
    vector<vector<long long>>dp(n+1,vector<long long>(n*n+1,-1e18));
    dp[0][0]=0;
    for(auto [a,b,c]:a)
    {
        vector<vector<long long>>ndp(n+1,vector<long long>(n*n+1,-1e18));
        for(int x=0;x<=n;x++)
        for(int y=0;y<=n*n;y++)
        if(dp[x][y]>=0)
        {
            ndp[x+1][y+x+1]=max(ndp[x+1][y+x+1],dp[x][y]+a);
            ndp[x][y+x]=max(ndp[x][y+x],dp[x][y]+1ll*b*y);
            ndp[x][y+x]=max(ndp[x][y+x],dp[x][y]+1ll*c*x);
        }
        dp=move(ndp);
    }
    long long ans=0;
    for(int x=0;x<=n;x++)
    for(int y=0;y<=n*n;y++)
    ans=max(ans,dp[x][y]);
    cout<<ans<<endl;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

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

input:

3
2
3 1 2
3 1 2
3
3 1 2
3 1 2
3 1 2
5
3 1 2
3 1 2
3 1 2
3 1 2
3 1 2

output:

6
10
24

result:

ok 3 tokens

Test #2:

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

input:

10
9
985316877 155474968 205618566
673963089 804780772 700375990
773310815 270690312 886710273
429186492 901607068 815288652
195900531 485188631 304895844
43482024 939904826 690756439
388004204 151760713 217460516
969581593 939366204 515765308
550802429 619082679 142828840
9
775490158 363365601 5596...

output:

46046207280
54618092606
69330112500
36314673040
29079238123
46503304041
96329186262
32034473543
61794614016
69914275970

result:

ok 10 tokens

Test #3:

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

input:

10
8
763281342 230025358 807878017
424443889 566631646 738675897
168624994 732275639 967007408
407643951 812903202 131102443
120406503 856675084 916359008
982933528 746980897 433850339
605549754 49124314 939090326
281904655 881219994 259080031
10
890017279 314916720 93897976
285786577 596890805 7027...

output:

35753806061
53550394187
56342905164
41868399882
58943093163
46844404571
61391071064
22881373659
64447995442
35816603535

result:

ok 10 tokens

Test #4:

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

input:

10
8
746845102 401966145 108968734
724807517 234978273 689554704
314651737 202893894 561139687
898413145 827040120 658667195
672111131 289078854 677550266
18894865 171446095 467098304
963764967 589786698 139330530
640602166 796810353 984853758
8
256643912 65415472 721122972
502739430 898469484 11806...

output:

26479152949
28273635023
52231969719
64233179285
13813886460
44065856029
53545189807
33649072437
22440663991
95246798238

result:

ok 10 tokens

Test #5:

score: 0
Accepted
time: 103ms
memory: 19072kb

input:

1
100
274029354 451706350 533961538
821588139 567794614 570933462
495899149 4333494 575397779
469851005 807667492 27535306
972538027 9373585 974395294
653920059 809644810 302668587
541273625 444143581 383964691
312391147 480844993 105475771
405588009 222700457 115086326
552237809 526608045 566455612...

output:

64630753156383

result:

ok "64630753156383"

Test #6:

score: 0
Accepted
time: 72ms
memory: 14868kb

input:

1
90
754865930 734198747 495036590
448647587 574079446 601039917
296505155 912455802 214812139
688669167 606768553 662214381
868436564 628086962 65646493
35412367 903740278 371555372
170277021 342414606 323329651
231352751 982962231 334360319
107969626 777276681 403269073
642364783 798619436 8530413...

output:

52955249062191

result:

ok "52955249062191"

Test #7:

score: 0
Accepted
time: 76ms
memory: 16436kb

input:

1
94
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 100000000...

output:

103870000000000

result:

ok "103870000000000"

Test #8:

score: 0
Accepted
time: 65ms
memory: 14808kb

input:

1
90
161197968 59659 3722680
152430471 35143 2705502
52672070 29458 1024946
109885555 26867 2460383
85923143 68705 2322578
117107375 14448 1649013
125701369 31675 1550101
13115713 88884 1080916
115301202 36620 3392702
100413347 1266 2046179
45298246 81828 3142580
29148478 46829 1975107
153911536 183...

output:

7808184899

result:

ok "7808184899"

Test #9:

score: 0
Accepted
time: 98ms
memory: 17580kb

input:

1
97
2228 13165 226164
33029782 13428 223049
33667012 5174 1068625
12377951 2928 1030463
40622436 11415 485736
9465175 3541 490823
13650906 12074 698031
4440534 23849 593296
41898918 5721 321774
18385367 23899 1175401
21761784 12187 796912
4176972 26468 236081
38509641 13583 974662
4107847 8229 7239...

output:

2615273632

result:

ok "2615273632"

Test #10:

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

input:

10
9
5384889 278746 738208
4089942 196733 108696
3943522 407469 1775031
2463366 424530 989073
6949015 991737 1109562
5060334 1350391 86302
1654284 1561580 1229856
1887965 387411 1093668
389880 2815725 939553
9
4629185 114460 320954
4717190 26171 1255061
2097127 32796 591034
2027329 331199 665613
457...

output:

44465288
24733502
93552928
75850892
95945523
121807368
118360697
28171014
21512111
41142631

result:

ok 10 tokens

Test #11:

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

input:

10
10
15388532 664211 2369970
17187364 212273 2818072
782512 3395 2516772
2946444 888278 8024
4682218 730694 6762
599251 1608984 1861607
7193768 827171 2822104
2029577 2007422 916633
964313 926807 625194
62895 8004161 1571712
9
9963877 351701 486689
11275556 138394 1889455
9352898 608670 2608938
700...

output:

100918502
62103780
32055068
126258108
94431605
43353246
116034812
60080832
23541554
24436794

result:

ok 10 tokens

Test #12:

score: 0
Accepted
time: 68ms
memory: 15232kb

input:

1
91
7 18 9
7 6 4
307385578 8 10
7 131634 16583665
5 1 10
999568980 9 11
15 190198 3
20 106489 9
880938309 18 12
503788570 15 18145926
6 11 7840892
9 295825 6008074
9 13 13
12 94706 5
1 5 13
18 9 3
7 2 12
13 90160 10
16 18029 19256978
14 3 5
252769876 5 4
6 12 14
3 12 470820
20 7 3
6 18 13
6 379719 ...

output:

18340279198

result:

ok "18340279198"

Test #13:

score: 0
Accepted
time: 91ms
memory: 16896kb

input:

1
95
144677535 6 5
232846882 13 18
6 2 2
626783022 13 9
9 5 20
17 3 12
12 19 10
19 19 9
9 222873 18052572
4 9569 15
391253118 15 19152813
15 18 20
2 193147 15
15 10 19
20 96682 8107958
741849468 7859 14
9 299006 11360222
3 20 19288049
1 15 20
8 367226 19022209
442758163 4 3
4 29288 6219032
6 2 20
38...

output:

29401853195

result:

ok "29401853195"

Test #14:

score: 0
Accepted
time: 76ms
memory: 15232kb

input:

1
91
6 17 12474580
18 7 2
3 370370 10
10 2 708333
7 17 5
7 61324 13
4 16 20
504030440 2 15
6 7 3
20 19 16
2 17 11301844
11 7 1
14 13 18
19 43206 13
3 19 14523968
20 9 17
17 152999 7464119
420409073 12 15
417208511 17 3304930
16 15 18
10 361629 16801270
11 311908 2
1 14 6
15 2 11207953
1 6 20
19 11 1...

output:

15931029343

result:

ok "15931029343"

Test #15:

score: 0
Accepted
time: 82ms
memory: 16440kb

input:

1
94
6 16 8
13 18 15
16 6 8
4 5 14
14 16 20
16 2 11
2 10 2
9 5 9
14 9 4
16 8 18
11 18 16
19 8 20
10 1 3
6 10 14
10 3 15
5 10 9
4 20 2
17 12 17
10 2 5
6 11 20
10 3 3
7 3 20
7 10 19
7 8 17
17 7 17
2 2 17
7 19 17
12 16 12
3 13 15
3 16 11
5 14 10
8 15 6
14 19 15
19 1 5
5 11 17
13 6 11
7 6 8
11 18 11
20 ...

output:

1058990

result:

ok "1058990"

Test #16:

score: 0
Accepted
time: 71ms
memory: 16000kb

input:

1
93
10 19 4
10 16 2
10 9 5
19 11 18
18 3 4
5 4 15
18 19 13
12 19 5
15 12 17
12 15 8
10 15 6
4 20 11
12 19 7
1 13 5
16 20 13
18 9 8
13 20 18
10 13 9
20 2 15
17 18 3
14 13 11
1 8 17
6 9 8
16 7 13
5 8 4
4 14 9
5 16 6
6 5 17
15 11 4
18 3 20
1 5 1
1 10 19
6 13 8
9 1 14
10 7 1
12 20 15
2 3 9
12 5 13
17 1...

output:

1210246

result:

ok "1210246"

Extra Test:

score: 0
Extra Test Passed