# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894776 | ksujay2 | Chorus (JOI23_chorus) | C++17 | 1452 ms | 75336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Line {
ll m, b, s;
ll eval(ll x) { return m * x + b; }
};
int main() {
int N, K; cin >> N >> K;
string s; cin >> s;
vector<int> h(N);
int x = 0, y = 0;
for(int i = 0; i < 2 * N; i++) {
if(s[i] == 'A') h[x] = y, x++;
else y++;
}
auto f = [&] (ll k) {
vector<pair<int, Line>> cht;
int best = 0;
vector<pair<ll, ll>> dp(N + 1);
ll g = 0;
int j = 0;
for(int i = 0; i < N; i++) {
while(j <= h[i] && j <= i) {
Line l;
l.m = -j;
l.b = dp[j].first - g + (ll) i * j;
while(cht.size() > 0) {
if(cht.back().second.eval(cht.back().second.s) > l.eval(cht.back().second.s)) cht.pop_back();
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |