QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#358161#6823. Coffee Overdosecrsfaa#WA 87ms3848kbC++14789b2024-03-19 17:50:592024-03-19 17:50:59

Judging History

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

  • [2024-04-08 20:49:53]
  • hack成功,自动添加数据
  • (/hack/589)
  • [2024-03-19 17:50:59]
  • 评测
  • 测评结果:WA
  • 用时:87ms
  • 内存:3848kb
  • [2024-03-19 17:50:59]
  • 提交

answer

#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
#define int long long
using Yukinoshita Yukino;
int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') w=ch=='-'?-1:1,ch=getchar();
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
int dp[1000000];
signed main()
{
	int T=read();
	while(T--)
	{
		int s=read(),c=read(),i,sum=0;
		for(;;)
		{
			if(s<1000) break;
			sum+=c*s,s-=c+1;
		}
//		printf("%lld\n",sum);
		for(i=1;i<=s;i++)
		{
			dp[i]=max(dp[i-1]+i,dp[max(0ll,i-c-1)]+c*i);
//			if(dp[i]==dp[i-1]+i) break;
		}
		printf("%lld\n",sum+dp[max(0ll,s)]);
//		cout<<i<<endl;
//		for(int i=1;i<=s;i++)
//			cout<<i<<':'<<dp[i]-dp[i-1]<<endl;
//		cout<<dp[s]<<endl;
//		printf("%lld\n",)
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 17ms
memory: 3756kb

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: 33ms
memory: 3760kb

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: 51ms
memory: 3848kb

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: 69ms
memory: 3700kb

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: -100
Wrong Answer
time: 87ms
memory: 3764kb

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:

wrong answer 99501st words differ - expected: '500500', found: '499501'