QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#265837 | #5647. Another Wine Tasting Event | BitsPlease# | WA | 91ms | 21172kb | C++20 | 1.1kb | 2023-11-25 21:35:07 | 2023-11-25 21:35:08 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cout << vars << " = ";
string delim = "";
(..., (cout << delim << values, delim = ", "));
cout << '\n';
}
using ld = long double;
void solve() {
int n;
string s;
cin >> n >> s;
auto check = [&] (int g) {
ll all = 0;
vector<int> pos;
for (int i = 0; i < 2 * n - 1; ++i) {
if (s[i] == 'W') pos.push_back(i);
if (pos.size() < g) continue;
int l = pos.size() - g;
if (i - n + 1 <= (l ? pos[l - 1] : -n*3)) continue;
assert(l >= 0);
all += (pos[l] - (l ? pos[l - 1] : 0));
}
return all >= n;
};
int l = 1, r = n * 2 - 1, best = 0;
while (l <= r) {
int m = (l + r) / 2;
if (check(m)) {
best = m;
l = m + 1;
} else r = m - 1;
}
cout << best << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while(t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
input:
5 RWWRRRWWW
output:
3
result:
ok At least n intervals
Test #2:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
1 R
output:
0
result:
ok At least n intervals
Test #3:
score: -100
Wrong Answer
time: 91ms
memory: 21172kb
input:
1000000 WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW...
output:
0
result:
wrong answer Not enough intervals