Submission #1588426


Source Code Expand

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する

int main() {
    int N;
    string S;
    cin >> N >> S;
    int max_v = 0;
    int val = 0;
    REP(i,0,S.size()){
        if(S[i] == 'I'){
            val++;
        }else{
            val--;
        }
        max_v = max(val,max_v);
    }

    cout << max_v << endl;

    return 0;
}

Submission Info

Submission Time
Task B - Increment Decrement
User homesentinel
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1555 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 10
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