| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1356546 | free_de_la_zenith | Monochrome Points (JOI20_monochrome) | C++20 | 10 ms | 2520 KiB |
/**
* author: MINHTPC
*
**/
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin() , a.end()
#define FOR(i ,a , b) for(int i = a ; i <= b ; ++i)
#define bit(mask,i) ((mask>>i)&1)
#define name "task"
#define lo lower_bound
#define up upper_bound
#define count_bit1(x) __builtin_popcountll(x)
#define count_bit01(x) __builtin_clzll(x)
#define count_bit10(x) __builtin_ctzll(x)
using namespace std;
const int N=6e5+5;
string s;
int pre[N];
int n;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
if(fopen("umnik.inp","r")) {
freopen("umnik.inp","r",stdin);
}
cin >> n;
cin >> s;
for(int i=0;i<2*n;i++) {
if(s[i]=='B') pre[i]+=1;
else {
int ni=(i+n)%(2*n);
pre[ni]--;
}
}
for(int i=1;i<2*n;i++) pre[i]+=pre[i-1];
sort(pre,pre+2*n);
int med=pre[n-1];
ll ans=1LL*n*(n-1);
for(int i=0;i<2*n;i++) ans-=abs(med-pre[i]);
cout << ans/2;
}
컴파일 시 표준 에러 (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... | ||||
