Submission #2562675


Source Code Expand

Copy
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> E(N+1,0), W(N+1,0);
  for(int i = 0; i < N; ++i) E[i+1] += E[i] + (S[i] == 'E');
  for(int i = N-1; i >= 0; --i) W[i] += W[i+1] + (S[i] == 'W');
  int ans = N;
  for(int i = 0; i < N; ++i){
    ans = min(ans, N - E[i] - W[i]);
  }
  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task C - Attention
User TAB
Language C++14 (GCC 5.4.1)
Score 0
Code Size 416 Byte
Status
Exec Time 13 ms
Memory 3076 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 0 / 300 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 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
subtask_1_01.txt 12 ms 2692 KB
subtask_1_02.txt 3 ms 768 KB
subtask_1_03.txt 9 ms 2052 KB
subtask_1_04.txt 9 ms 2052 KB
subtask_1_05.txt 5 ms 1280 KB
subtask_1_06.txt 13 ms 2948 KB
subtask_1_07.txt 13 ms 2948 KB
subtask_1_08.txt 13 ms 2820 KB
subtask_1_09.txt 10 ms 2308 KB
subtask_1_10.txt 13 ms 2948 KB
subtask_1_11.txt 13 ms 2948 KB
subtask_1_12.txt 13 ms 2948 KB
subtask_1_13.txt 13 ms 3076 KB
subtask_1_14.txt 13 ms 2948 KB
subtask_1_15.txt 13 ms 3076 KB
subtask_1_16.txt 13 ms 2948 KB
subtask_1_17.txt 13 ms 2948 KB
subtask_1_18.txt 13 ms 3076 KB
subtask_1_19.txt 13 ms 2948 KB
subtask_1_20.txt 13 ms 2948 KB