QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#44177#3622. Weighty TomesLangdao_ZhangAC ✓252ms4944kbC++1.2kb2022-08-13 14:04:392022-08-13 14:04:41

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-13 14:04:41]
  • 评测
  • 测评结果:AC
  • 用时:252ms
  • 内存:4944kb
  • [2022-08-13 14:04:39]
  • 提交

answer

#include<iostream>

#define maxn 5003
#define maxm 21
#define inf 998244353

using
		namespace
					std;

int n,m;
int dp[maxn][maxm],l[maxn][maxm],r[maxn][maxm];

void prework(){
	
	//dp[i][0]=inf
	//dp[i][1]=i
	//dp[i][2]=min(max(dp[x][1],dp[y][2])), x+y=i
	//dp[i][j]=min(max(dp[x][j-1],dp[y][j])), x+y=i
	
	//l[i][1]=r[i][1]=1
	
	for(int i=0;i<maxn;i++) dp[i][1]=i-1;
	
	for(int i=0;i<maxn;i++) l[i][1]=r[i][1]=1;
	
	for(int j=2;j<maxm;j++){
		
		//dp[0][j]=0;
		dp[1][j]=0;
		dp[2][j]=1;
		
		for(int i=3;i<maxn;i++){
			
			dp[i][j]=inf;
			l[i][j]=inf,r[i][j]=-inf;
			
			for(int x=1;x<i;x++){
				
				int nxt=max(dp[x-1][j-1],dp[i-x][j])+1;
				
				if(nxt<=dp[i][j]){
					
					if(nxt==dp[i][j]){
						r[i][j]=x;
					}
					else{
						dp[i][j]=nxt;
						l[i][j]=r[i][j]=x;
					}
				}
			}
		}
	}
	
//	for(int i=1;i<=100;i++){
//		
//		for(int j=1;j<=10;j++){
//			
//			cout<<dp[i][j]<<' ';
//		}
//		cout<<endl;
//	}
}

signed main(){
	
	prework();
	
	cin>>n>>m;
	
	cout<<dp[n][m]+1<<' ';
	if(l[n][m]==r[n][m]){
		cout<<l[n][m]<<endl;
	}
	else{
		cout<<l[n][m]<<'-'<<r[n][m]<<endl;
	}
	
end:
	return EOF+1;
}

詳細信息

Test #1:

score: 100
Accepted
time: 230ms
memory: 4812kb

input:

3 1

output:

3 1

result:

ok single line: '3 1'

Test #2:

score: 0
Accepted
time: 235ms
memory: 4868kb

input:

3 2

output:

2 2

result:

ok single line: '2 2'

Test #3:

score: 0
Accepted
time: 225ms
memory: 4924kb

input:

4 2

output:

3 1-3

result:

ok single line: '3 1-3'

Test #4:

score: 0
Accepted
time: 227ms
memory: 4868kb

input:

5000 20

output:

13 905-4096

result:

ok single line: '13 905-4096'

Test #5:

score: 0
Accepted
time: 230ms
memory: 4808kb

input:

5000 10

output:

13 918-4017

result:

ok single line: '13 918-4017'

Test #6:

score: 0
Accepted
time: 232ms
memory: 4944kb

input:

5000 5

output:

16 57-1941

result:

ok single line: '16 57-1941'

Test #7:

score: 0
Accepted
time: 229ms
memory: 4812kb

input:

5000 1

output:

5000 1

result:

ok single line: '5000 1'

Test #8:

score: 0
Accepted
time: 230ms
memory: 4788kb

input:

4000 20

output:

12 1953-2048

result:

ok single line: '12 1953-2048'

Test #9:

score: 0
Accepted
time: 236ms
memory: 4808kb

input:

4000 10

output:

12 1954-2036

result:

ok single line: '12 1954-2036'

Test #10:

score: 0
Accepted
time: 237ms
memory: 4812kb

input:

4000 5

output:

15 528-1471

result:

ok single line: '15 528-1471'

Test #11:

score: 0
Accepted
time: 245ms
memory: 4824kb

input:

4000 1

output:

4000 1

result:

ok single line: '4000 1'

Test #12:

score: 0
Accepted
time: 241ms
memory: 4812kb

input:

3000 20

output:

12 953-2048

result:

ok single line: '12 953-2048'

Test #13:

score: 0
Accepted
time: 242ms
memory: 4928kb

input:

3000 10

output:

12 954-2036

result:

ok single line: '12 954-2036'

Test #14:

score: 0
Accepted
time: 227ms
memory: 4812kb

input:

3000 5

output:

14 621-1093

result:

ok single line: '14 621-1093'

Test #15:

score: 0
Accepted
time: 233ms
memory: 4876kb

input:

3000 1

output:

3000 1

result:

ok single line: '3000 1'

Test #16:

score: 0
Accepted
time: 235ms
memory: 4928kb

input:

100 1

output:

100 1

result:

ok single line: '100 1'

Test #17:

score: 0
Accepted
time: 231ms
memory: 4740kb

input:

100 2

output:

14 9-14

result:

ok single line: '14 9-14'

Test #18:

score: 0
Accepted
time: 228ms
memory: 4812kb

input:

100 3

output:

9 8-37

result:

ok single line: '9 8-37'

Test #19:

score: 0
Accepted
time: 233ms
memory: 4940kb

input:

100 4

output:

8 2-64

result:

ok single line: '8 2-64'

Test #20:

score: 0
Accepted
time: 239ms
memory: 4808kb

input:

100 5

output:

7 38-57

result:

ok single line: '7 38-57'

Test #21:

score: 0
Accepted
time: 232ms
memory: 4880kb

input:

100 6

output:

7 37-63

result:

ok single line: '7 37-63'

Test #22:

score: 0
Accepted
time: 233ms
memory: 4844kb

input:

100 7

output:

7 37-64

result:

ok single line: '7 37-64'

Test #23:

score: 0
Accepted
time: 225ms
memory: 4812kb

input:

100 8

output:

7 37-64

result:

ok single line: '7 37-64'

Test #24:

score: 0
Accepted
time: 231ms
memory: 4740kb

input:

100 9

output:

7 37-64

result:

ok single line: '7 37-64'

Test #25:

score: 0
Accepted
time: 234ms
memory: 4792kb

input:

100 10

output:

7 37-64

result:

ok single line: '7 37-64'

Test #26:

score: 0
Accepted
time: 252ms
memory: 4820kb

input:

100 11

output:

7 37-64

result:

ok single line: '7 37-64'

Test #27:

score: 0
Accepted
time: 234ms
memory: 4924kb

input:

100 12

output:

7 37-64

result:

ok single line: '7 37-64'

Test #28:

score: 0
Accepted
time: 251ms
memory: 4872kb

input:

100 13

output:

7 37-64

result:

ok single line: '7 37-64'

Test #29:

score: 0
Accepted
time: 233ms
memory: 4824kb

input:

100 14

output:

7 37-64

result:

ok single line: '7 37-64'

Test #30:

score: 0
Accepted
time: 226ms
memory: 4784kb

input:

100 15

output:

7 37-64

result:

ok single line: '7 37-64'

Test #31:

score: 0
Accepted
time: 233ms
memory: 4872kb

input:

100 16

output:

7 37-64

result:

ok single line: '7 37-64'

Test #32:

score: 0
Accepted
time: 231ms
memory: 4796kb

input:

100 17

output:

7 37-64

result:

ok single line: '7 37-64'

Test #33:

score: 0
Accepted
time: 231ms
memory: 4808kb

input:

100 18

output:

7 37-64

result:

ok single line: '7 37-64'

Test #34:

score: 0
Accepted
time: 231ms
memory: 4940kb

input:

100 19

output:

7 37-64

result:

ok single line: '7 37-64'

Test #35:

score: 0
Accepted
time: 232ms
memory: 4784kb

input:

100 20

output:

7 37-64

result:

ok single line: '7 37-64'

Test #36:

score: 0
Accepted
time: 234ms
memory: 4736kb

input:

10 5

output:

4 3-8

result:

ok single line: '4 3-8'

Test #37:

score: 0
Accepted
time: 226ms
memory: 4824kb

input:

10 2

output:

4 4

result:

ok single line: '4 4'

Test #38:

score: 0
Accepted
time: 232ms
memory: 4940kb

input:

10 10

output:

4 3-8

result:

ok single line: '4 3-8'

Test #39:

score: 0
Accepted
time: 229ms
memory: 4872kb

input:

10 15

output:

4 3-8

result:

ok single line: '4 3-8'

Test #40:

score: 0
Accepted
time: 236ms
memory: 4876kb

input:

10 20

output:

4 3-8

result:

ok single line: '4 3-8'

Test #41:

score: 0
Accepted
time: 231ms
memory: 4812kb

input:

2441 3

output:

25 117-301

result:

ok single line: '25 117-301'

Test #42:

score: 0
Accepted
time: 229ms
memory: 4868kb

input:

2011 3

output:

23 218-254

result:

ok single line: '23 218-254'

Test #43:

score: 0
Accepted
time: 225ms
memory: 4928kb

input:

2945 13

output:

12 898-2048

result:

ok single line: '12 898-2048'

Test #44:

score: 0
Accepted
time: 233ms
memory: 4928kb

input:

3449 11

output:

12 1402-2047

result:

ok single line: '12 1402-2047'

Test #45:

score: 0
Accepted
time: 230ms
memory: 4944kb

input:

3019 11

output:

12 972-2047

result:

ok single line: '12 972-2047'

Test #46:

score: 0
Accepted
time: 238ms
memory: 4928kb

input:

3952 1

output:

3952 1

result:

ok single line: '3952 1'