QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#74708#5035. foo~chengzk0 13ms5680kbC++141.6kb2023-02-03 14:06:112023-02-03 14:06:11

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-03 14:06:11]
  • 评测
  • 测评结果:0
  • 用时:13ms
  • 内存:5680kb
  • [2023-02-03 14:06:11]
  • 提交

answer

#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define mid (l+r)/2
#define ls roo*2
#define rs roo*2+1
using namespace std;
const int N=800000+5,K=50+5;
const long long Inf=1e18;
int n,k,rt,a[N],las1[N],las2[N],f[K][N],f2[N];
int tot,top,que[N],b[N],ans;
void solve()
{
	for (int i=1;i<=k;i++)
	  for (int j=0;j<=n;j++)
	    f[i][j]=0;
	top=0;
	for (int j=n;j>=1;j--){while (top&&b[que[top]]<b[j]) top--;las1[j]=que[top];que[++top]=j;}
	top=0;
	for (int j=1;j<=n;j++){while (top&&b[que[top]]<b[j]) top--;las2[j]=que[top];que[++top]=j;}
//	for (int i=0;i<=n;i++) cout<<b[i]<<" ";cout<<endl;
//	for (int i=0;i<=n;i++) cout<<las1[i]<<" ";cout<<endl;
//	for (int i=0;i<=n;i++) cout<<las2[i]<<" ";cout<<endl;
	for (int i=1;i<=k;i++)
	{
		for (int j=0;j<=n;j++) f2[j]=j?f[i-1][j-1]+1:0;
		for (int j=1;j<=n;j++)if (las1[j]) f2[las1[j]]=max(f2[las1[j]],f2[j]+1);
		for (int j=1;j<=n;j++) f2[j]=max(f2[j],f2[j-1]);
		for (int j=0;j<=n;j++) f[i][j]=max(f[i][j],f2[j]);//pre
		
		for (int j=0;j<=n;j++) f2[j]=j?max(f2[j-1],f[i-1][j-1]+1):0;
		for (int j=0;j<=n;j++)  if (las2[j]) f2[j]=max(f2[j],f2[las2[j]]+1);
//		for (int j=n;j>=0;j--) f2[j]=max(f2[j],f2[j+1]);
		for (int j=0;j<=n;j++) f[i][j]=max(f[i][j],f2[j]);//beh
	}//ad序列末尾 
	ans=max(ans,f[k][n]);
}
int main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),rt=(a[i]==n)?i:rt;
	tot=0;
	for (int i=rt;i<=n;i++)b[++tot]=a[i];
	for (int i=1;i<rt;i++) b[++tot]=a[i];
	solve();
	tot=0;
	for (int i=rt;i>=1;i--)b[++tot]=a[i];
	for (int i=n;i>rt;i--) b[++tot]=a[i];
	solve();
	cout<<ans;
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 2ms
memory: 3480kb

input:

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

output:

20

result:

ok "20"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

13 6
13 9 3 4 12 6 5 1 8 10 11 7 2

output:

13

result:

ok "13"

Test #3:

score: 0
Accepted
time: 2ms
memory: 3464kb

input:

25 3
25 2 3 19 5 6 7 11 8 10 9 20 4 14 21 1 17 12 13 18 15 22 23 16 24

output:

16

result:

ok "16"

Test #4:

score: 0
Accepted
time: 2ms
memory: 3680kb

input:

25 9
1 11 10 23 9 24 7 8 19 3 5 21 18 12 15 16 17 13 2 20 14 22 4 6 25

output:

23

result:

ok "23"

Test #5:

score: 0
Accepted
time: 2ms
memory: 3336kb

input:

13 2
1 4 2 3 5 6 7 8 9 10 12 11 13

output:

12

result:

ok "12"

Test #6:

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

input:

17 5
4 2 3 6 5 1 7 8 13 16 11 12 9 14 15 10 17

output:

15

result:

ok "15"

Test #7:

score: 0
Accepted
time: 2ms
memory: 3460kb

input:

8 2
1 2 5 6 3 4 7 8

output:

8

result:

ok "8"

Test #8:

score: 0
Accepted
time: 2ms
memory: 3472kb

input:

11 5
3 11 2 10 6 5 1 4 8 7 9

output:

11

result:

ok "11"

Test #9:

score: 0
Accepted
time: 2ms
memory: 3608kb

input:

10 1
5 3 4 1 10 8 9 6 7 2

output:

6

result:

ok "6"

Test #10:

score: -10
Wrong Answer
time: 2ms
memory: 3648kb

input:

16 2
15 12 14 9 11 13 1 3 10 8 5 2 16 4 6 7

output:

10

result:

wrong answer 1st words differ - expected: '9', found: '10'

Subtask #2:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 13ms
memory: 5680kb

input:

93943 1
87243 48984 50611 19218 77699 25025 85769 28141 13380 34875 42459 66419 53472 4367 48292 16894 92171 87263 42527 67085 30687 29235 27515 81053 31421 34864 83591 70491 75344 7026 50250 63402 26773 5330 36308 76399 80032 15501 16205 71750 73964 67876 68901 70548 2043 79979 89479 19784 38838 44...

output:

24

result:

wrong answer 1st words differ - expected: '25', found: '24'

Subtask #3:

score: 0
Wrong Answer

Test #36:

score: 0
Wrong Answer
time: 3ms
memory: 3976kb

input:

1992 25
144 612 1315 1966 1779 1773 1529 625 36 1849 1783 1441 1388 1558 1258 724 137 397 542 353 1162 1213 406 792 1317 882 994 298 1864 1969 103 449 508 1501 89 1721 195 778 657 222 1152 1780 613 743 1206 694 829 142 69 1973 1465 1343 655 1540 155 146 350 491 759 1695 1082 1357 1329 1745 232 1850 ...

output:

236

result:

wrong answer 1st words differ - expected: '237', found: '236'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #2:

0%