Submission #3248764
Source Code Expand
#include<stdio.h> #include<math.h> #include<iostream> #include<string.h> using namespace std; #define maxn 1e6; int main() { int n; char s[110]; int ls, t; int i, j; int a[110]; int max; scanf("%d", &n); scanf("%s", &s); ls = strlen(s); memset(a, 0, sizeof(a)); a[0] = 0; for(i = 0; i < ls; i++) { if(s[i] == 'D') a[i + 1] = a[i] - 1; else a[i + 1] = a[i] + 1; } max = a[0]; for(i = 1; i <=ls; i++) { if(max < a[i]) { t = max; max = a[i]; a[i] = t; } } printf("%d\n", max); //for(i = 0; i < ls; i++) // printf("%c\n", s[i]); // printf("%d\n", ls); }
Submission Info
Submission Time | |
---|---|
Task | B - Increment Decrement |
User | vjudge3 |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 631 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:16:17: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘char (*)[110]’ [-Wformat=] scanf("%s", &s); ^ ./Main.cpp:15:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:16:18: 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 | sample_01.txt, sample_02.txt, 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 | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |
subtask_1_alld_01.txt | AC | 1 ms | 256 KB |
subtask_1_alldmax_01.txt | AC | 1 ms | 256 KB |
subtask_1_alli_01.txt | AC | 1 ms | 256 KB |
subtask_1_allimax_01.txt | AC | 1 ms | 256 KB |
subtask_1_max_01.txt | AC | 1 ms | 256 KB |
subtask_1_max_02.txt | AC | 1 ms | 256 KB |
subtask_1_rand_01.txt | AC | 1 ms | 256 KB |
subtask_1_rand_02.txt | AC | 1 ms | 256 KB |