QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#774215#5459. Goose, goose, DUCK?Yurily#WA 1ms5736kbC++20710b2024-11-23 12:28:542024-11-23 12:29:01

Judging History

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

  • [2024-11-23 12:29:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5736kb
  • [2024-11-23 12:28:54]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N=1000010;
int n,k,a[N],num[N]={0};
vector<pair<int,int> > g;

void sol(){
    int l=1;
    for(int i=1;i<=n;i++){
        num[a[i]]++;
        if(num[a[i]]==k){
            while(num[a[i]]==k){
                num[a[l++]]--;
            }
            g.push_back(make_pair(i,l));
        }
    }
    g.push_back(make_pair(n+1,n+1));
    int ans=n*(n+1)/2,cnt=0;
    for(int i=0;i<g.size();i++){
        if(i!=0){
            cnt+=(g[i].first-g[i-1].first)*(g[i-1].second-1);
        }
    }
    cout<<ans-cnt<<"\n";
}

signed main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    sol();
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5644kb

input:

6 2
1 2 2 1 3 3

output:

10

result:

ok 1 number(s): "10"

Test #2:

score: 0
Accepted
time: 1ms
memory: 5616kb

input:

6 1
1 2 3 4 5 6

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 5736kb

input:

100 10
142826 764475 142826 986320 764475 142826 142826 986320 764475 986320 764475 764475 764475 142826 142826 986320 764475 986320 764475 764475 142826 764475 142826 764475 986320 986320 764475 142826 764475 764475 142826 764475 764475 986320 142826 142826 142826 142826 764475 986320 986320 764475...

output:

1943

result:

wrong answer 1st numbers differ - expected: '4309', found: '1943'