QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#204390 | #7567. Joining Cats | ucup-team918# | WA | 305ms | 199444kb | C++20 | 2.3kb | 2023-10-07 11:00:54 | 2023-10-07 11:00:56 |
Judging History
answer
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 5005
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define ld long double
#define ls (rt<<1)
#define rs ((rt<<1)|1)
#define SZ(x) (int)(x.size())
#define debug cout<<endl<<"ff"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define fi first
#define se second
#define INF 1e9
#define pq priority_queue
#define rep(x,a,b) for(int x=a;x<=b;x++)
/*int fac[N],ifac[N];
int C(int n,int m){
if(m>n||m<0||n<0) return 0;
return fac[n]*ifac[n-m]%mod*ifac[m]%mod;
}
void init(){
fac[0]=1;
for(int i=1;i<N;i++) fac[i]=fac[i-1]*i%mod;
ifac[N-1]=qpow(fac[N-1],mod-2);
for(int i=N-2;i>=0;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
}*/
/*struct node{
int nxt,to;
}e[N<<1];
int cnt=1,head[N];
inline void add(int x,int y){
e[++cnt].nxt=head[x];
head[x]=cnt;
e[cnt].to=y;
}*/
inline int lowbit(int x){return x&(-x);}
inline int read(){
int x=0,t=1;char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-') t=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=(x<<1)+(x<<3)+(ch-'0');
ch=getchar();
}
return x*t;
}
inline void write(int x){
if(x<0) putchar('-'),x=-x;
if(x>=10) write(x/10);
putchar(x%10+'0');
}
int T,n,k,dp[2][N],L[N][N],R[N][N],w[N],t[N],cnt,a[N];
ll s[N];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>a[i],s[i]=s[i-1]+a[i];
for(int i=1;i<=k;i++) cin>>w[i],t[i]=w[i];
sort(t+1,t+n+1);cnt=unique(t+1,t+n+1)-t-1;
for(int i=1;i<=k;i++) w[i]=lower_bound(t+1,t+cnt+1,w[i])-t;
for(int i=1;i<=n;i++){
int now=i;
for(int j=1;j<=cnt;j++){
while(now!=1&&s[i-1]-s[now-2]<=t[j]) now--;
L[i][j]=now;
}
}
for(int i=1;i<=n;i++){
int now=i;
for(int j=1;j<=cnt;j++){
while(now!=n&&s[now+1]-s[i]<=t[j]) now++;
R[i][j]=now;
}
}
for(int i=1;i<=n;i++) dp[0][i]=i;
//dp[i][j]表示前i个,在左端点=i时,右端点最大
int now=0,pre=1;
for(int i=1;i<=k;i++){
now^=1;pre^=1;
for(int j=1;j<=n;j++){
dp[now][j]=max(dp[now][j],R[dp[pre][j]][w[i]]);
dp[now][L[j][w[i]]]=max(dp[now][L[j][w[i]]],dp[pre][j]);
dp[now][j]=max(dp[now][j],dp[pre][j]);
}
}
if(dp[now][1]==n) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5772kb
input:
5 2 1 1 1 1 1 2 2
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 1ms
memory: 7772kb
input:
6 7 3 2 1 1 2 3 2 2 2 2 2 2 2
output:
No
result:
ok answer is NO
Test #3:
score: 0
Accepted
time: 1ms
memory: 5776kb
input:
7 4 1 2 3 4 3 2 1 3 3 3 3
output:
Yes
result:
ok answer is YES
Test #4:
score: 0
Accepted
time: 1ms
memory: 5784kb
input:
5 1 5 4 3 2 1 10
output:
Yes
result:
ok answer is YES
Test #5:
score: 0
Accepted
time: 298ms
memory: 199416kb
input:
5000 5000 775487425 856128884 277783434 903422359 477267301 475103384 297595527 426167697 732858986 408894759 274205836 78265305 841664344 827278645 235744961 539622829 661053351 709331224 497285040 688977639 794889854 890450616 730989757 164925481 519732355 5132018 793806705 617096813 966338860 838...
output:
No
result:
ok answer is NO
Test #6:
score: 0
Accepted
time: 305ms
memory: 199444kb
input:
5000 5000 719129447 937392296 350445117 783330021 802155515 695380072 535475671 613171233 926763173 500405367 828284512 931492995 720877462 919465915 260912626 876806990 884762137 576596567 928561233 974405439 891740632 540536614 879167622 725668608 801467926 601260355 706621299 926987536 994204742 ...
output:
No
result:
ok answer is NO
Test #7:
score: 0
Accepted
time: 288ms
memory: 199364kb
input:
5000 5000 416747559 657602574 449451106 121890071 441124856 144632709 177533820 169507188 105623279 399624204 458468079 481561977 54065647 407303452 627276664 15195167 482406549 98222656 788603298 66301460 298650558 502696353 90244701 498415278 210561025 368288994 77615125 176971936 438514087 804772...
output:
No
result:
ok answer is NO
Test #8:
score: 0
Accepted
time: 23ms
memory: 43356kb
input:
1000 5000 652378395 9226710 369514617 603608037 161741291 783580574 951641399 734721388 223516311 671669592 479702806 414081589 624003108 605424248 896097938 156346340 669596794 597103379 732027711 334398013 586620215 764336953 962550397 952888036 385377097 271706418 466047181 667473147 451787252 34...
output:
Yes
result:
ok answer is YES
Test #9:
score: -100
Wrong Answer
time: 15ms
memory: 45324kb
input:
1000 5000 872227273 712283986 920948311 507385120 918594985 900251115 743516868 670907467 867435817 714475407 652551933 758876839 384367533 880301180 841974114 886109922 903272749 893904997 942686977 997058175 645506447 529091876 716946215 871179658 785614131 908004811 934740746 911599923 901612611 ...
output:
No
result:
wrong answer expected YES, found NO