제출 #52141

#제출 시각아이디문제언어결과실행 시간메모리
52141ainta스탬프 수집 (JOI16_ho_t2)C++17
100 / 100
5 ms3488 KiB
#include<cstdio>
#include<algorithm>
using namespace std;
int C[101000][3];
int n;
char p[101000];
long long s = 0, res, s2 = 0, M;
int main() {
	int i, j;
	scanf("%d", &n);
	scanf("%s", p + 1);
	for (i = 1; i <= n; i++) {
		for (j = 0; j < 3; j++)C[i][j] = C[i - 1][j];
		if (p[i] == 'J')C[i][0]++;
		if (p[i] == 'O') {
			s += C[i][0];
			C[i][1]++;
		}
		if (p[i] == 'I') {
			C[i][2]++;
			res += s;
		}
	}
	int c = 0;
	for (i = n; i >= 1; i--) {
		if (p[i] == 'I')c++;
		if (p[i] == 'O')s2 += c;
	}
	M = max(s2, s);
	for (i = 0; i <= n; i++) {
		M = max(M, 1ll*C[i][0] * (C[n][2] - C[i][2]));
	}
	printf("%lld\n", res + M);
}

컴파일 시 표준 에러 (stderr) 메시지

2016_ho_t2.cpp: In function 'int main()':
2016_ho_t2.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
2016_ho_t2.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", p + 1);
  ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...