Submission #121137

# Submission time Handle Problem Language Result Execution time Memory
121137 2019-06-26T07:04:10 Z 이온조(#2969) Growing Vegetable is Fun 3 (JOI19_ho_t3) C++14
15 / 100
3 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

int N, ans = 1e9;
char S[444];

void f(int st) {
	int s = 0;
	for(int i=1, j=st; i<=N; i++) {
		if(S[i] == 'R') s += max(i - j, j - i), j += 2;
	}
	ans = min(ans, s);
}

int main() {
	int c = 0; scanf("%d",&N);
	for(int i=1; i<=N; i++) {
		scanf(" %c", &S[i]);
		if(S[i] == 'R') ++c;
	}
	if(N%2 == 0 && c*2 == N) {f(1); f(2);}
	if(N%2 && c*2-1 == N) f(1);
	if(N%2 && c*2+1 == N) f(2);
	if(ans == 1e9) puts("-1");
	else printf("%d", ans);
	return 0;
}

Compilation message

joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int c = 0; scanf("%d",&N);
             ~~~~~^~~~~~~~~
joi2019_ho_t3.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c", &S[i]);
   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 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 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -