Submission #1695737
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
int f(string s) {
int ret = 0;
int cnt = 0;
REP(i, 1, s.size()) {
if(s[i-1] == '2' && s[i] == '5') cnt += 2, ++i;
else cnt = 0;
ret = max(ret, cnt);
}
return ret;
}
int calc(string t) {
string s;
for(auto& c : t) {
if(c == '?') s += (s.size()&1 ? '5' : '2');
else s += c;
}
return f(s);
}
int main(){
#ifdef LOCAL_TEST
freopen("in", "r", stdin);
freopen("out", "w", stdout);
#endif
string s;
cin >> s;
cout << max(calc(s), calc(s.substr(1))) << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
B - ニコニコレベル |
User |
T1610 |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1169 Byte |
Status |
AC |
Exec Time |
7 ms |
Memory |
808 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt |
All |
sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, large_01.txt, large_02.txt, large_03.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt |
Case Name |
Status |
Exec Time |
Memory |
hand_01.txt |
AC |
1 ms |
256 KB |
hand_02.txt |
AC |
1 ms |
256 KB |
hand_03.txt |
AC |
1 ms |
256 KB |
hand_04.txt |
AC |
1 ms |
256 KB |
hand_05.txt |
AC |
6 ms |
808 KB |
large_01.txt |
AC |
7 ms |
808 KB |
large_02.txt |
AC |
7 ms |
808 KB |
large_03.txt |
AC |
7 ms |
808 KB |
random_01.txt |
AC |
7 ms |
808 KB |
random_02.txt |
AC |
7 ms |
808 KB |
random_03.txt |
AC |
6 ms |
808 KB |
random_04.txt |
AC |
7 ms |
808 KB |
sample_01.txt |
AC |
1 ms |
256 KB |
sample_02.txt |
AC |
1 ms |
256 KB |
sample_03.txt |
AC |
1 ms |
256 KB |
sample_04.txt |
AC |
1 ms |
256 KB |
sample_05.txt |
AC |
1 ms |
256 KB |