QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#733025#5459. Goose, goose, DUCK?ChensenCHX#WA 1ms5956kbC++23891b2024-11-10 16:53:462024-11-10 16:53:47

Judging History

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

  • [2024-11-10 16:53:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5956kb
  • [2024-11-10 16:53:46]
  • 提交

answer

#include <iostream>
using namespace std;
const int N = 1e6 + 10;
typedef long long LL;
LL a[N];
LL q[N], tt, hh;
int vis[N];
LL ans;

void solve() {
    LL n, k;
    scanf("%lld%lld", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
    }
    LL last = 0;
    for (int i = 1; i <= n; i++) {
        if (++vis[a[i]] == k) {
            LL tmp = tt - last;
            LL tmp1 = tmp * (tmp + 1) / 2;
            ans += tmp1 + tmp * (last - hh);
        }
        while (hh <= tt && vis[a[i]] == k) {
            hh++;
            vis[a[q[hh]]]--;
            
            last = tt;
        }
        q[++tt] = i;
    }
    if (hh <= tt) {
        LL tmp = tt - last;
        LL tmp1 = tmp * (tmp + 1) / 2;
        ans += tmp1 + tmp * (last - hh);
    }
    printf("%lld\n", ans);
}

int main() {
    solve();
    return 0;
}

詳細信息

Test #1:

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

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: 5956kb

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: 5948kb

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'