QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#760990#5035. foo~qwqUwU_0 0ms20180kbC++141.4kb2024-11-18 20:31:042024-11-18 20:31:05

Judging History

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

  • [2024-11-18 20:31:05]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:20180kb
  • [2024-11-18 20:31:04]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
#define P make_pair
#define fi first
#define se second
#define bit(s,x) (((s)>>(x))&1)
#define pnp(s) __builtin_popcountll(s)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll; 
typedef unsigned long long ull;
typedef pair<int,int> pii;
inline ll read(){
	ll x=0,f=1,c=getchar();
	while(c<'0'||c>'9')f=(c=='-'?-1:1),c=getchar();
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
const int N=6e5+3;
int n,K,p[N],a[N];
int F[2][N],*f=F[0],*g=F[1];
int st[N],b[N],c[N],d[N];
inline int solve(){
	memset(f,-0x7f,sizeof F[0]);
	int tp=0,mx1=0;
	f[0]=0;
	d[0]=INT_MIN;
	rep(_,1,K){
		g[0]=0;
		rep(i,1,n){
			int mx=f[i-1],mx2=f[i-1];
			for(;tp&&a[st[tp]]<a[i];--tp){
				mx=max(mx,b[tp]);
				mx2=max(mx2,c[tp]+tp);
			}
			st[++tp]=i,b[tp]=mx+1,c[tp]=mx2-tp;
			d[tp]=max(d[tp-1],c[tp]);
			mx1=max(mx1,mx+1);
			g[i]=max(mx1,d[tp]+tp+1);
		}
		swap(f,g);
	}
	int ans=0;
	rep(i,0,n)ans=max(ans,f[i]);
	return ans;
}
int main() {
    //freopen("data.in", "r", stdin);
    // freopen("myans.out","w",stdout);
	n=read(),K=read();rep(i,1,n)p[i]=read();
	int ans=0;
	rep(i,1,n)if(p[i]==n){
		rep(j,1,n)a[j]=p[i+j-1>n?i+j-1-n:i+j-1];
		ans=max(ans,solve());
		rep(j,1,n)a[j]=p[i+j>n?i+j-n:i+j];
		ans=max(ans,solve());
		printf("%d",ans);
		return 0;
	}
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 18180kb

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:

25

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 0ms
memory: 18184kb

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: 0ms
memory: 20180kb

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:

281

result:

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

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #2:

0%