QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#234668 | #5543. The Only Mode | dmmm# | WA | 0ms | 3688kb | C++17 | 1.0kb | 2023-11-01 20:39:02 | 2023-11-01 20:39:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 1e5 + 6.9;
const int INF = 1e18;
int n;
int a[MAXN];
int pre[MAXN];
int num[MAXN][4];
int check(int len, int val) {
for (int i = 1; i + len - 1 <= n; i++) {
int cnt = num[i + len - 1][val] - num[i - 1][val];
int ok = 1;
for (int j = 0; j < 4; j++) {
if (j == val) continue;
if (cnt <= num[i + len - 1][j] - num[i - 1][j]) ok = 0;
}
if (ok) return 1;
}
return 0;
}
int bin(int l, int r, int val) {
while (l < r) {
int mid = (l + r) / 2 + 1;
if (check(mid, val)) {
l = mid;
}
else {
r = mid - 1;
}
}
return l;
}
void solve(int val) {
cout << bin(0, n, val) << ' ';
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 4; j++) num[i][j] = num[i - 1][j];
num[i][a[i]]++;
}
for (int i = 0; i < 4; i++) solve(i);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3688kb
input:
7 1 2 2 0 3 0 3
output:
4 1 5 1
result:
wrong answer 1st lines differ - expected: '4 1 5 3', found: '4 1 5 1 '