QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#264264#6823. Coffee Overdosevp_account#WA 2682ms3960kbC++141.3kb2023-11-25 13:27:242023-11-25 13:27:24

Judging History

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

  • [2024-04-08 20:49:53]
  • hack成功,自动添加数据
  • (/hack/589)
  • [2023-11-25 13:27:24]
  • 评测
  • 测评结果:WA
  • 用时:2682ms
  • 内存:3960kb
  • [2023-11-25 13:27:24]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int s,c,ans,T;
int read(){
	int x=0,f=1;char ch=getchar();
	while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
	return x*f;
}
int f(int x,int y){
	int mid=y+(x-1)*c; if (mid>s) return -y;
	return ((s+mid+1)*(s-mid)+(c-1)*(y+mid)*x)>>1;
}
signed main(){
	T=read();while (T--){
		s=read();c=read()+1;ans=0;  
		/*for (int i=0;i<=(s-1)/c+1;i++)
			for (int j=1;j<=s;j++)
				ans=max(ans,f(i,j)); */
		const int limit=(s-1)/(c-1)+1;
		for (int i=max(limit-100,0ll);i<=limit;i++){
			int l=0,r=s,res=s;while (l+2<r){
				int mid1=l+(r-l)/3,mid2=l+(r-l)/3*2;
				int ans1=f(i,mid1),ans2=f(i,mid2);
				if (ans1>=ans2) res=mid1,r=mid2;
				else res=mid2,l=mid1;
			}
			for (int j=max(0ll,res-20);j<=min(s,res+20);j++) ans=max(ans,f(i,j));
			for (int j=max(0ll,s-20);j<=s;j++) ans=max(ans,f(i,j));
		}
		for (int i=0;i<=min(100ll,limit);i++){
			int l=0,r=s,res=s;while (l+2<r){
				int mid1=l+(r-l)/3,mid2=l+(r-l)/3*2;
				int ans1=f(i,mid1),ans2=f(i,mid2);
				if (ans1>=ans2) res=mid1,r=mid2;
				else res=mid2,l=mid1;
			}
			for (int j=max(0ll,res-20);j<=min(s,res+20);j++) ans=max(ans,f(i,j));
			for (int j=max(0ll,s-20);j<=s;j++) ans=max(ans,f(i,j));
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
1 2
2 1
10 4
172800 172800

output:

2
3
63
29859840000

result:

ok 4 tokens

Test #2:

score: 0
Accepted
time: 48ms
memory: 3828kb

input:

100000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 ...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...

result:

ok 100000 tokens

Test #3:

score: 0
Accepted
time: 118ms
memory: 3848kb

input:

100000
201 1
201 2
201 3
201 4
201 5
201 6
201 7
201 8
201 9
201 10
201 11
201 12
201 13
201 14
201 15
201 16
201 17
201 18
201 19
201 20
201 21
201 22
201 23
201 24
201 25
201 26
201 27
201 28
201 29
201 30
201 31
201 32
201 33
201 34
201 35
201 36
201 37
201 38
201 39
201 40
201 41
201 42
201 43
2...

output:

20301
20302
20304
20309
20316
20328
20343
20365
20391
20426
20466
20517
20574
20644
20721
20813
20913
21030
21156
21301
21435
21588
21735
21837
22001
22152
22248
22359
22533
22680
22785
22848
22974
23154
23310
23436
23532
23598
23634
23801
23985
24150
24295
24420
24525
24610
24675
24720
24745
24901
...

result:

ok 100000 tokens

Test #4:

score: 0
Accepted
time: 175ms
memory: 3844kb

input:

100000
401 1
401 2
401 3
401 4
401 5
401 6
401 7
401 8
401 9
401 10
401 11
401 12
401 13
401 14
401 15
401 16
401 17
401 18
401 19
401 20
401 21
401 22
401 23
401 24
401 25
401 26
401 27
401 28
401 29
401 30
401 31
401 32
401 33
401 34
401 35
401 36
401 37
401 38
401 39
401 40
401 41
401 42
401 43
4...

output:

80601
80602
80604
80609
80616
80628
80643
80665
80691
80726
80766
80817
80874
80944
81021
81113
81213
81330
81456
81601
81756
81932
82119
82329
82551
82798
83058
83345
83636
83916
84227
84448
84759
85068
85260
85551
85877
86108
86256
86601
86920
87150
87290
87531
87885
88182
88407
88560
88641
89001
...

result:

ok 100000 tokens

Test #5:

score: 0
Accepted
time: 219ms
memory: 3764kb

input:

100000
601 1
601 2
601 3
601 4
601 5
601 6
601 7
601 8
601 9
601 10
601 11
601 12
601 13
601 14
601 15
601 16
601 17
601 18
601 19
601 20
601 21
601 22
601 23
601 24
601 25
601 26
601 27
601 28
601 29
601 30
601 31
601 32
601 33
601 34
601 35
601 36
601 37
601 38
601 39
601 40
601 41
601 42
601 43
6...

output:

180901
180902
180904
180909
180916
180928
180943
180965
180991
181026
181066
181117
181174
181244
181321
181413
181513
181630
181756
181901
182056
182232
182419
182629
182851
183098
183358
183645
183946
184276
184621
184997
185389
185814
186256
186661
187117
187568
187921
188401
188805
189133
189630...

result:

ok 100000 tokens

Test #6:

score: 0
Accepted
time: 253ms
memory: 3824kb

input:

100000
801 1
801 2
801 3
801 4
801 5
801 6
801 7
801 8
801 9
801 10
801 11
801 12
801 13
801 14
801 15
801 16
801 17
801 18
801 19
801 20
801 21
801 22
801 23
801 24
801 25
801 26
801 27
801 28
801 29
801 30
801 31
801 32
801 33
801 34
801 35
801 36
801 37
801 38
801 39
801 40
801 41
801 42
801 43
8...

output:

321201
321202
321204
321209
321216
321228
321243
321265
321291
321326
321366
321417
321474
321544
321621
321713
321813
321930
322056
322201
322356
322532
322719
322929
323151
323398
323658
323945
324246
324576
324921
325297
325689
326114
326556
327033
327528
328060
328611
329201
329770
330378
330885...

result:

ok 100000 tokens

Test #7:

score: 0
Accepted
time: 305ms
memory: 3808kb

input:

100000
1001 1
1001 2
1001 3
1001 4
1001 5
1001 6
1001 7
1001 8
1001 9
1001 10
1001 11
1001 12
1001 13
1001 14
1001 15
1001 16
1001 17
1001 18
1001 19
1001 20
1001 21
1001 22
1001 23
1001 24
1001 25
1001 26
1001 27
1001 28
1001 29
1001 30
1001 31
1001 32
1001 33
1001 34
1001 35
1001 36
1001 37
1001 3...

output:

501501
501502
501504
501509
501516
501528
501543
501565
501591
501626
501666
501717
501774
501844
501921
502013
502113
502230
502356
502501
502656
502832
503019
503229
503451
503698
503958
504245
504546
504876
505221
505597
505989
506414
506856
507333
507828
508360
508911
509501
510111
510762
511434...

result:

ok 100000 tokens

Test #8:

score: 0
Accepted
time: 342ms
memory: 3852kb

input:

100000
1201 1
1201 2
1201 3
1201 4
1201 5
1201 6
1201 7
1201 8
1201 9
1201 10
1201 11
1201 12
1201 13
1201 14
1201 15
1201 16
1201 17
1201 18
1201 19
1201 20
1201 21
1201 22
1201 23
1201 24
1201 25
1201 26
1201 27
1201 28
1201 29
1201 30
1201 31
1201 32
1201 33
1201 34
1201 35
1201 36
1201 37
1201 3...

output:

721801
721802
721804
721809
721816
721828
721843
721865
721891
721926
721966
722017
722074
722144
722221
722313
722413
722530
722656
722801
722956
723132
723319
723529
723751
723998
724258
724545
724846
725176
725521
725897
726289
726714
727156
727633
728128
728660
729211
729801
730411
731062
731734...

result:

ok 100000 tokens

Test #9:

score: 0
Accepted
time: 383ms
memory: 3788kb

input:

100000
1401 1
1401 2
1401 3
1401 4
1401 5
1401 6
1401 7
1401 8
1401 9
1401 10
1401 11
1401 12
1401 13
1401 14
1401 15
1401 16
1401 17
1401 18
1401 19
1401 20
1401 21
1401 22
1401 23
1401 24
1401 25
1401 26
1401 27
1401 28
1401 29
1401 30
1401 31
1401 32
1401 33
1401 34
1401 35
1401 36
1401 37
1401 3...

output:

982101
982102
982104
982109
982116
982128
982143
982165
982191
982226
982266
982317
982374
982444
982521
982613
982713
982830
982956
983101
983256
983432
983619
983829
984051
984298
984558
984845
985146
985476
985821
986197
986589
987014
987456
987933
988428
988960
989511
990101
990711
991362
992034...

result:

ok 100000 tokens

Test #10:

score: 0
Accepted
time: 427ms
memory: 3760kb

input:

100000
1601 1
1601 2
1601 3
1601 4
1601 5
1601 6
1601 7
1601 8
1601 9
1601 10
1601 11
1601 12
1601 13
1601 14
1601 15
1601 16
1601 17
1601 18
1601 19
1601 20
1601 21
1601 22
1601 23
1601 24
1601 25
1601 26
1601 27
1601 28
1601 29
1601 30
1601 31
1601 32
1601 33
1601 34
1601 35
1601 36
1601 37
1601 3...

output:

1282401
1282402
1282404
1282409
1282416
1282428
1282443
1282465
1282491
1282526
1282566
1282617
1282674
1282744
1282821
1282913
1283013
1283130
1283256
1283401
1283556
1283732
1283919
1284129
1284351
1284598
1284858
1285145
1285446
1285776
1286121
1286497
1286889
1287314
1287756
1288233
1288728
1289...

result:

ok 100000 tokens

Test #11:

score: 0
Accepted
time: 453ms
memory: 3768kb

input:

100000
1801 1
1801 2
1801 3
1801 4
1801 5
1801 6
1801 7
1801 8
1801 9
1801 10
1801 11
1801 12
1801 13
1801 14
1801 15
1801 16
1801 17
1801 18
1801 19
1801 20
1801 21
1801 22
1801 23
1801 24
1801 25
1801 26
1801 27
1801 28
1801 29
1801 30
1801 31
1801 32
1801 33
1801 34
1801 35
1801 36
1801 37
1801 3...

output:

1622701
1622702
1622704
1622709
1622716
1622728
1622743
1622765
1622791
1622826
1622866
1622917
1622974
1623044
1623121
1623213
1623313
1623430
1623556
1623701
1623856
1624032
1624219
1624429
1624651
1624898
1625158
1625445
1625746
1626076
1626421
1626797
1627189
1627614
1628056
1628533
1629028
1629...

result:

ok 100000 tokens

Test #12:

score: 0
Accepted
time: 487ms
memory: 3832kb

input:

100000
2001 1
2001 2
2001 3
2001 4
2001 5
2001 6
2001 7
2001 8
2001 9
2001 10
2001 11
2001 12
2001 13
2001 14
2001 15
2001 16
2001 17
2001 18
2001 19
2001 20
2001 21
2001 22
2001 23
2001 24
2001 25
2001 26
2001 27
2001 28
2001 29
2001 30
2001 31
2001 32
2001 33
2001 34
2001 35
2001 36
2001 37
2001 3...

output:

2003001
2003002
2003004
2003009
2003016
2003028
2003043
2003065
2003091
2003126
2003166
2003217
2003274
2003344
2003421
2003513
2003613
2003730
2003856
2004001
2004156
2004332
2004519
2004729
2004951
2005198
2005458
2005745
2006046
2006376
2006721
2007097
2007489
2007914
2008356
2008833
2009328
2009...

result:

ok 100000 tokens

Test #13:

score: 0
Accepted
time: 528ms
memory: 3852kb

input:

100000
2201 1
2201 2
2201 3
2201 4
2201 5
2201 6
2201 7
2201 8
2201 9
2201 10
2201 11
2201 12
2201 13
2201 14
2201 15
2201 16
2201 17
2201 18
2201 19
2201 20
2201 21
2201 22
2201 23
2201 24
2201 25
2201 26
2201 27
2201 28
2201 29
2201 30
2201 31
2201 32
2201 33
2201 34
2201 35
2201 36
2201 37
2201 3...

output:

2423301
2423302
2423304
2423309
2423316
2423328
2423343
2423365
2423391
2423426
2423466
2423517
2423574
2423644
2423721
2423813
2423913
2424030
2424156
2424301
2424456
2424632
2424819
2425029
2425251
2425498
2425758
2426045
2426346
2426676
2427021
2427397
2427789
2428214
2428656
2429133
2429628
2430...

result:

ok 100000 tokens

Test #14:

score: 0
Accepted
time: 567ms
memory: 3900kb

input:

100000
2401 1
2401 2
2401 3
2401 4
2401 5
2401 6
2401 7
2401 8
2401 9
2401 10
2401 11
2401 12
2401 13
2401 14
2401 15
2401 16
2401 17
2401 18
2401 19
2401 20
2401 21
2401 22
2401 23
2401 24
2401 25
2401 26
2401 27
2401 28
2401 29
2401 30
2401 31
2401 32
2401 33
2401 34
2401 35
2401 36
2401 37
2401 3...

output:

2883601
2883602
2883604
2883609
2883616
2883628
2883643
2883665
2883691
2883726
2883766
2883817
2883874
2883944
2884021
2884113
2884213
2884330
2884456
2884601
2884756
2884932
2885119
2885329
2885551
2885798
2886058
2886345
2886646
2886976
2887321
2887697
2888089
2888514
2888956
2889433
2889928
2890...

result:

ok 100000 tokens

Test #15:

score: 0
Accepted
time: 593ms
memory: 3776kb

input:

100000
2601 1
2601 2
2601 3
2601 4
2601 5
2601 6
2601 7
2601 8
2601 9
2601 10
2601 11
2601 12
2601 13
2601 14
2601 15
2601 16
2601 17
2601 18
2601 19
2601 20
2601 21
2601 22
2601 23
2601 24
2601 25
2601 26
2601 27
2601 28
2601 29
2601 30
2601 31
2601 32
2601 33
2601 34
2601 35
2601 36
2601 37
2601 3...

output:

3383901
3383902
3383904
3383909
3383916
3383928
3383943
3383965
3383991
3384026
3384066
3384117
3384174
3384244
3384321
3384413
3384513
3384630
3384756
3384901
3385056
3385232
3385419
3385629
3385851
3386098
3386358
3386645
3386946
3387276
3387621
3387997
3388389
3388814
3389256
3389733
3390228
3390...

result:

ok 100000 tokens

Test #16:

score: 0
Accepted
time: 613ms
memory: 3852kb

input:

100000
2801 1
2801 2
2801 3
2801 4
2801 5
2801 6
2801 7
2801 8
2801 9
2801 10
2801 11
2801 12
2801 13
2801 14
2801 15
2801 16
2801 17
2801 18
2801 19
2801 20
2801 21
2801 22
2801 23
2801 24
2801 25
2801 26
2801 27
2801 28
2801 29
2801 30
2801 31
2801 32
2801 33
2801 34
2801 35
2801 36
2801 37
2801 3...

output:

3924201
3924202
3924204
3924209
3924216
3924228
3924243
3924265
3924291
3924326
3924366
3924417
3924474
3924544
3924621
3924713
3924813
3924930
3925056
3925201
3925356
3925532
3925719
3925929
3926151
3926398
3926658
3926945
3927246
3927576
3927921
3928297
3928689
3929114
3929556
3930033
3930528
3931...

result:

ok 100000 tokens

Test #17:

score: 0
Accepted
time: 2682ms
memory: 3900kb

input:

100000
65736 108
24887 113
159544 70
12349 17
91631 27
146066 107
56687 66
2562 19
147238 56
159826 4
14887 102
84794 41
85967 17
30607 70
49900 99
31408 97
143135 107
133056 110
119397 67
40784 18
4708 72
83644 42
61024 83
148356 41
48676 105
70198 72
134683 76
8939 61
50201 76
172010 60
164070 2
2...

output:

2160801180
309874176
12727266615
76255687
4198168353
10667864328
1606772265
3284058
10839609893
12772255059
110951479
3595062225
3695206140
468452403
1245151225
493361008
10244038797
8852182471
7127919090
831688449
11131642
3498210451
1862066263
11004834156
1184845516
2463961357
9069877458
39985695
...

result:

ok 100000 tokens

Test #18:

score: -100
Wrong Answer
time: 194ms
memory: 3960kb

input:

100000
39208 149121
45640 144937
102575 159062
132644 44622
95175 84007
9029 84051
72508 98666
128196 45604
74948 51707
88570 42898
13696 64851
49130 144102
144177 63497
99292 107759
25888 159908
70627 132791
36596 99767
25146 39785
10890 159277
148608 5893
21785 95593
166407 51391
47097 37344
70711...

output:

5846736168
6614924680
16315784650
11783019186
8933472394
758896479
7154074328
11299439892
5077006916
5877583674
888199296
7079731260
15368623389
10699606628
4139698304
9378629957
3651073132
1000433610
1734526530
11481084394
2082493505
18360770916
2122969056
7075766926
6876073022
9679115250
322428548...

result:

wrong answer 3551st words differ - expected: '13076942116', found: '13076558971'