QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#586377#9258. Huawei Frequencies Selectionucup-team3474WA 4ms16104kbC++201.2kb2024-09-24 11:40:422024-09-24 11:40:42

Judging History

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

  • [2024-09-24 11:40:42]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:16104kb
  • [2024-09-24 11:40:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef long long ll;
typedef pair<ll,ll> PII;
ll n,m,k;
ll a[N],b[N];
char s[N];
vector<int> e[N];
int dep[N];
int ne[N][2];

bool judge0(){
    int cnt=0;
    for(int i=1;i<=n;i++) if(a[i]==0) cnt++;
    return cnt>=k;
}



int dp[N];
int last[N];

bool judge1(){
    int lst=1;
    int mx=0,mx1=-1e9;
    memset(dp,-0x3f,sizeof dp);
    dp[0]=0;
    for(int i=1;i<=n;i++){
        if(a[i]==0){
            dp[i]=mx1+1;
        }else{
            dp[i]=mx+1;
        }
        mx=max(mx,dp[i]);
        if(a[i]==1) mx1=max(mx1,dp[i-1]);
    }
    // cout<<mx<<endl;
    return dp[n]>=k;
}


bool judge2(){
    int lst=-1;
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(a[i]==2) return true;
        else if(a[i]<=1){
            if(lst!=a[i]){
                cnt++;
                lst=a[i];
            }
        }
    }
    return cnt<=k;
}




void __(){
    cin>>n>>k;
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    if(judge0()){
        puts("0");
    }else if(judge1()) puts("1");
    else if(judge2()) puts("2");
    else puts("3");
}


int main(){
    int _=1;
    // cin>>_;
    while(_--){
        __();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 15892kb

input:

2 2
0 2

output:

2

result:

ok answer is '2'

Test #2:

score: 0
Accepted
time: 4ms
memory: 13924kb

input:

3 1
2 1 1

output:

1

result:

ok answer is '1'

Test #3:

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

input:

3 2
1 3 0

output:

2

result:

ok answer is '2'

Test #4:

score: 0
Accepted
time: 3ms
memory: 15972kb

input:

20 15
1 2 2 0 3 3 2 2 2 0 1 1 2 1 3 1 0 2 2 1

output:

1

result:

ok answer is '1'

Test #5:

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

input:

9 4
0 0 2 1 3 1 3 0 3

output:

1

result:

ok answer is '1'

Test #6:

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

input:

19 17
1 0 0 3 0 0 2 3 1 0 3 3 3 1 3 0 0 3 1

output:

2

result:

ok answer is '2'

Test #7:

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

input:

17 15
0 0 3 0 1 1 2 1 2 1 1 1 3 0 0 1 0

output:

2

result:

ok answer is '2'

Test #8:

score: 0
Accepted
time: 3ms
memory: 16088kb

input:

6 5
2 1 3 0 1 0

output:

2

result:

ok answer is '2'

Test #9:

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

input:

16 12
0 2 0 1 2 0 0 0 1 3 3 0 1 0 3 1

output:

2

result:

ok answer is '2'

Test #10:

score: -100
Wrong Answer
time: 3ms
memory: 15916kb

input:

15 9
0 2 2 1 2 0 3 3 1 0 1 1 1 0 1

output:

1

result:

wrong answer expected '2', found '1'