Submission #397161

#TimeUsernameProblemLanguageResultExecution timeMemory
397161phathnvMonochrome Points (JOI20_monochrome)C++11
35 / 100
2082 ms3036 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; string s; vector<int> b, w; ll Calc(int k){ ll res = 0; int j = k; for(int i = 0; i < n; i++){ int dist = abs(b[i] - w[j]); res += min(dist, 2 * n - dist); j = (j == n - 1? 0 : j + 1); } return res; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> s; for(int i = 0; i < 2 * n; i++) if (s[i] == 'B') b.push_back(i); else w.push_back(i); ll answer = 0; for(int k = 0; k < n; k++) answer = max(answer, Calc(k)); cout << (answer - n) / 2; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...