# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
121160 | 2019-06-26T07:20:28 Z | 윤교준(#2970) | Growing Vegetable is Fun 3 (JOI19_ho_t3) | C++14 | 3 ms | 384 KB |
#include <bits/stdc++.h> #define INF (0x3f3f3f3f) using namespace std; char A[555], _A[555]; int N, Ans = INF; void solve() { int ret = 0; for(int i = 1, j; i <= N; i++) { char c = (i&1) ? 'R' : 'G'; if(A[i] == c) continue; for(j = i+1; j <= N && A[j] != c; j++); if(N < j) return; swap(A[i], A[j]); ret += j-i; } if(ret < Ans) Ans = ret; } int main() { scanf("%d %s", &N, A+1); for(int i = 1; i <= N; i++) _A[i] = A[i]; solve(); for(int i = 1; i <= N; i++) A[i] = _A[i]^'R'^'G'; solve(); cout << (INF <= Ans ? -1 : Ans) << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Incorrect | 3 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Incorrect | 3 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Incorrect | 3 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |