QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#732966 | #5459. Goose, goose, DUCK? | ChensenCHX# | WA | 1ms | 5960kb | C++23 | 887b | 2024-11-10 16:41:26 | 2024-11-10 16:41:26 |
Judging History
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 - hh;
LL tmp1 = tmp * (tmp + 1) / 2;
ans += tmp1 + tmp * (hh - last);
}
while (hh <= tt && vis[a[i]] == k) {
hh++;
vis[a[q[hh]]]--;
last = hh;
}
q[++tt] = i;
}
if (hh <= tt) {
LL tmp = tt - hh;
LL tmp1 = tmp * (tmp + 1) / 2;
ans += tmp1 + tmp * (hh - last);
}
printf("%lld\n", ans);
}
int main() {
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5960kb
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: 5948kb
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: 5944kb
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:
8842
result:
wrong answer 1st numbers differ - expected: '4309', found: '8842'