Submission #3004452
Source Code Expand
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> //#include <regex> /* g++ -g -std=c++0x */ /* g++ -g -std=c++11 */ using namespace std; // freopen("input.txt", "rt", stdin); // freopen("output.txt", "wt", stdout); #define ALL(c) (c).begin(), (c).end() #define ALLR(c) (c).rbegin(), (c).rend() #define FOR(i,a,b) for (int i=(a); i < (b); ++i) #define FORR(i,a,b) for (int i=(a); i > (b); --i) #define FOR_ALL(i,c) for (__typeof((c).begin()) i=(c).begin(); \ i != (c).end(); ++i) #define FOR_ALLR(i,c) for (__typeof((c).rbegin()) i=(c).rbegin(); \ i != (c).rend(); ++i) #define SZ(array) (sizeof(array)/sizeof(array[0])) #define lc(x) (x<<1) /* 2*x */ #define rc(x) (x<<1 | 1) /* 2*x+1 */ #define lowbit(x) (x & (-x)) /* 0b10100 -> 0b100 */ typedef long long LL; typedef map<int,int> MII; typedef pair<int,int> PII; typedef set<int> SI; typedef vector<bool> VB; typedef vector<double> VD; typedef vector<int> VI; typedef vector<string> VS; /* check if a key is in container C */ template <class C> inline bool in_(const typename C::key_type& k, const C& A) { return A.find(k) != A.end(); } inline bool in_(const string& s, const string& S) { return S.find(s) != string::npos; } int main() { /* #ifndef ONLINE_JUDGE */ /* freopen("foo", "rt", stdin); */ /* #endif */ std::ios::sync_with_stdio(false); int n; string s; while (cin >> n) { cin >> s; int x = 0, x2 = 0; FOR(i,0,n) { if (s[i] == 'I') x++; else x--; if (x > x2) x2 = x; } if (x2 > 0) cout << x2 << endl; else cout << '0' << endl; } }
Submission Info
Submission Time | |
---|---|
Task | B - Increment Decrement |
User | kopok |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 2265 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
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 |