Submission #1065512
Source Code Expand
#include <cstdio> #include <algorithm> using namespace std; int main() { int N; scanf("%d", &N); char S[N + 1]; scanf("%s", &S); S[N] = '\0'; int m = 0; int x = 0; int i; for (i = 0; i < N; i++) { if (S[i] == 'I') x++; else x--; m = max(m, x); } printf("%d\n", m); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Increment Decrement |
User | ishibashijun |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 392 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 128 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:14:19: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘char (*)[(N + 1)]’ [-Wformat=] scanf("%s", &S); ^ ./Main.cpp:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.cpp:14:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", &S); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
All | subtask_1_alld_01.txt, subtask_1_alldmax_01.txt, subtask_1_alli_01.txt, subtask_1_allimax_01.txt, subtask_1_max_01.txt, subtask_1_max_02.txt, subtask_1_rand_01.txt, subtask_1_rand_02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 1 ms | 128 KB |
sample_02.txt | AC | 1 ms | 128 KB |
subtask_1_alld_01.txt | AC | 1 ms | 128 KB |
subtask_1_alldmax_01.txt | AC | 1 ms | 128 KB |
subtask_1_alli_01.txt | AC | 1 ms | 128 KB |
subtask_1_allimax_01.txt | AC | 1 ms | 128 KB |
subtask_1_max_01.txt | AC | 1 ms | 128 KB |
subtask_1_max_02.txt | AC | 1 ms | 128 KB |
subtask_1_rand_01.txt | AC | 1 ms | 128 KB |
subtask_1_rand_02.txt | AC | 1 ms | 128 KB |