Submission #1241865


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



string A;
int dp[1010][2];
//-----------------------------------------------------------------------------------
int main() {
    cin >> A;
    reverse(A.begin(), A.end());

    rep(i, 0, 1010) rep(j, 0, 2) dp[i][j] = -1;
    dp[0][0] = 0;

    int n = A.length();
    rep(i, 0, n) rep(j, 0, 2) rep(k, 0, 10) if(0 <= dp[i][j]) {
        int c = A[i] - '0';

        int sm = c + k + j;

        int up = sm / 10;
        int down = sm % 10;

        if (k == down && down == c) dp[i + 1][up] = max(dp[i + 1][up], dp[i][j] + 1);
        else dp[i + 1][up] = max(dp[i + 1][up], dp[i][j]);
    }

    printf("%d\n", max(dp[n][0], dp[n][1]));
}

Submission Info

Submission Time
Task F - レシート
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 100
Code Size 758 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 53
Set Name Test Cases
Sample 00-example1.txt, 00-example2.txt, 00-example3.txt
All 00-example1.txt, 00-example2.txt, 00-example3.txt, 01-hand01.txt, 01-hand02.txt, 01-hand03.txt, 01-hand04.txt, 01-hand05.txt, 01-hand06.txt, 01-hand07.txt, 01-hand08.txt, 01-hand09.txt, 01-hand10.txt, 01-hand11.txt, 01-hand12.txt, 01-hand13.txt, 01-hand14.txt, 01-hand15.txt, 01-hand16.txt, 01-hand17.txt, 01-hand18.txt, 01-hand19.txt, 01-hand20.txt, 10-randomA00.txt, 10-randomA01.txt, 10-randomA02.txt, 10-randomA03.txt, 10-randomA04.txt, 10-randomA05.txt, 10-randomA06.txt, 10-randomA07.txt, 10-randomA08.txt, 10-randomA09.txt, 20-randomB00.txt, 20-randomB01.txt, 20-randomB02.txt, 20-randomB03.txt, 20-randomB04.txt, 20-randomB05.txt, 20-randomB06.txt, 20-randomB07.txt, 20-randomB08.txt, 20-randomB09.txt, 20-randomB10.txt, 20-randomB11.txt, 20-randomB12.txt, 20-randomB13.txt, 20-randomB14.txt, 20-randomB15.txt, 20-randomB16.txt, 20-randomB17.txt, 20-randomB18.txt, 20-randomB19.txt
Case Name Status Exec Time Memory
00-example1.txt AC 1 ms 256 KB
00-example2.txt AC 1 ms 256 KB
00-example3.txt AC 1 ms 256 KB
01-hand01.txt AC 1 ms 256 KB
01-hand02.txt AC 1 ms 256 KB
01-hand03.txt AC 1 ms 256 KB
01-hand04.txt AC 1 ms 256 KB
01-hand05.txt AC 1 ms 256 KB
01-hand06.txt AC 1 ms 256 KB
01-hand07.txt AC 1 ms 256 KB
01-hand08.txt AC 1 ms 256 KB
01-hand09.txt AC 1 ms 256 KB
01-hand10.txt AC 1 ms 256 KB
01-hand11.txt AC 1 ms 256 KB
01-hand12.txt AC 1 ms 256 KB
01-hand13.txt AC 1 ms 256 KB
01-hand14.txt AC 1 ms 256 KB
01-hand15.txt AC 1 ms 256 KB
01-hand16.txt AC 1 ms 256 KB
01-hand17.txt AC 1 ms 256 KB
01-hand18.txt AC 1 ms 256 KB
01-hand19.txt AC 1 ms 256 KB
01-hand20.txt AC 1 ms 256 KB
10-randomA00.txt AC 1 ms 256 KB
10-randomA01.txt AC 1 ms 256 KB
10-randomA02.txt AC 1 ms 256 KB
10-randomA03.txt AC 1 ms 256 KB
10-randomA04.txt AC 1 ms 256 KB
10-randomA05.txt AC 1 ms 256 KB
10-randomA06.txt AC 1 ms 256 KB
10-randomA07.txt AC 1 ms 256 KB
10-randomA08.txt AC 1 ms 256 KB
10-randomA09.txt AC 1 ms 256 KB
20-randomB00.txt AC 1 ms 256 KB
20-randomB01.txt AC 1 ms 256 KB
20-randomB02.txt AC 1 ms 256 KB
20-randomB03.txt AC 1 ms 256 KB
20-randomB04.txt AC 1 ms 256 KB
20-randomB05.txt AC 1 ms 256 KB
20-randomB06.txt AC 1 ms 256 KB
20-randomB07.txt AC 1 ms 256 KB
20-randomB08.txt AC 1 ms 256 KB
20-randomB09.txt AC 1 ms 256 KB
20-randomB10.txt AC 1 ms 256 KB
20-randomB11.txt AC 1 ms 256 KB
20-randomB12.txt AC 1 ms 256 KB
20-randomB13.txt AC 1 ms 256 KB
20-randomB14.txt AC 1 ms 256 KB
20-randomB15.txt AC 1 ms 256 KB
20-randomB16.txt AC 1 ms 256 KB
20-randomB17.txt AC 1 ms 256 KB
20-randomB18.txt AC 1 ms 256 KB
20-randomB19.txt AC 1 ms 256 KB