QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#453786 | #5459. Goose, goose, DUCK? | WTR2007 | WA | 2ms | 7848kb | C++20 | 1.3kb | 2024-06-24 11:39:34 | 2024-06-24 11:39:34 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define MULT_TEST 0
using namespace std;
typedef long double ldb;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
const int N = 1000006;
int col[N], from[N];
vector<int> E[N];
inline int read() {
int w = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
w = (w << 1) + (w << 3) + ch - 48;
ch = getchar();
}
return w * f;
}
inline void Solve() {
int n, k;
n = read(), k = read();
vector<int> T;
for (int i = 1; i <= n; i++) {
col[i] = read();
T.push_back(col[i]);
E[col[i]].push_back(i);
}
sort(T.begin(), T.end());
T.erase(unique(T.begin(), T.end()), T.end());
for (auto c : T) {
int sz = E[c].size();
for (int i = k - 1; i < sz; i++) from[E[c][i]] = E[c][i - k + 1];
}
int ans = 0, mx = 0;
for (int i = 1; i <= n; i++) {
mx = max(mx, from[i]);
ans += i - mx;
}
printf("%lld\n", ans);
}
signed main() {
int _ = 1;
#if MULT_TEST
_ = read();
#endif
while (_--) Solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7848kb
input:
6 2 1 2 2 1 3 3
output:
10
result:
ok 1 number(s): "10"
Test #2:
score: 0
Accepted
time: 2ms
memory: 7760kb
input:
6 1 1 2 3 4 5 6
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 2ms
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'