Submission #19455502


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n,ans,cur1,cur2,i;
	string s;
	cin >> n >> s;
	
	cur1=0; cur2=0;
	for(i=0; i<n; i++){
		if(s[i]=='E'){
			cur2++;
		}
	}
	ans=n-1;
	for(i=0; i<n; i++){
		if(s[i]=='E'){
			cur2--;
		}
		if(i>0 && s[i-1]=='W'){
			cur1++;
		}
		ans=min(ans,cur1+cur2);
	}
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task C - Attention
User T_Stream
Language C++ (GCC 9.2.1)
Score 300
Code Size 379 Byte
Status AC
Exec Time 17 ms
Memory 3896 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 26
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt
Case Name Status Exec Time Memory
sample_01.txt AC 7 ms 3560 KB
sample_02.txt AC 1 ms 3560 KB
sample_03.txt AC 2 ms 3520 KB
subtask_1_01.txt AC 17 ms 3808 KB
subtask_1_02.txt AC 4 ms 3632 KB
subtask_1_03.txt AC 8 ms 3672 KB
subtask_1_04.txt AC 9 ms 3672 KB
subtask_1_05.txt AC 8 ms 3700 KB
subtask_1_06.txt AC 12 ms 3700 KB
subtask_1_07.txt AC 11 ms 3780 KB
subtask_1_08.txt AC 11 ms 3824 KB
subtask_1_09.txt AC 11 ms 3672 KB
subtask_1_10.txt AC 14 ms 3712 KB
subtask_1_11.txt AC 15 ms 3708 KB
subtask_1_12.txt AC 13 ms 3776 KB
subtask_1_13.txt AC 11 ms 3780 KB
subtask_1_14.txt AC 15 ms 3780 KB
subtask_1_15.txt AC 13 ms 3708 KB
subtask_1_16.txt AC 12 ms 3828 KB
subtask_1_17.txt AC 15 ms 3780 KB
subtask_1_18.txt AC 12 ms 3896 KB
subtask_1_19.txt AC 13 ms 3808 KB
subtask_1_20.txt AC 14 ms 3780 KB