Submission #19724097


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    vec_int a(N); rep(i,N)cin>>a.at(i);

    vec_int DP(N+1, -1000000000);
    DP.at(0) = 0;

    for(int i=0;i<N;i++){
        DP.at(i+1) = max(DP.at(i+1), DP.at(i)); //i+1に何もおかなかったとき
        // i+1においてかつ、i+2+3j, i+3+3kに置いたとき
        int pos = i+2;
        while(pos<N){
            int max_val = -1000;
            int pos2 = i+1;
            while(pos2<pos){
                max_val = max(a.at(pos2), max_val);
                pos2 += 3;
            }
            DP.at(pos) = max(DP.at(pos), a.at(i)+max_val+a.at(pos));
            pos+=3;
        }
    }
    cout<<DP.at(N)<<endl;


    return 0;
}

Submission Info

Submission Time
Task B - Three Coins
User yunix
Language C++ (GCC 9.2.1)
Score 0
Code Size 1038 Byte
Status WA
Exec Time 15 ms
Memory 3648 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
AC × 3
AC × 4
WA × 45
Set Name Test Cases
Sample example0.txt, example1.txt, example2.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, example0.txt, example1.txt, example2.txt
Case Name Status Exec Time Memory
000.txt WA 10 ms 3488 KB
001.txt WA 7 ms 3648 KB
002.txt WA 8 ms 3448 KB
003.txt WA 8 ms 3512 KB
004.txt WA 8 ms 3452 KB
005.txt WA 8 ms 3512 KB
006.txt WA 5 ms 3512 KB
007.txt WA 6 ms 3644 KB
008.txt WA 10 ms 3536 KB
009.txt WA 10 ms 3488 KB
010.txt WA 6 ms 3512 KB
011.txt WA 7 ms 3608 KB
012.txt WA 6 ms 3616 KB
013.txt WA 10 ms 3648 KB
014.txt WA 6 ms 3432 KB
015.txt WA 6 ms 3592 KB
016.txt WA 11 ms 3532 KB
017.txt WA 6 ms 3572 KB
018.txt WA 7 ms 3616 KB
019.txt WA 7 ms 3504 KB
020.txt WA 5 ms 3512 KB
021.txt WA 5 ms 3436 KB
022.txt WA 6 ms 3612 KB
023.txt WA 6 ms 3612 KB
024.txt WA 6 ms 3616 KB
025.txt WA 7 ms 3572 KB
026.txt WA 8 ms 3436 KB
027.txt WA 6 ms 3452 KB
028.txt WA 4 ms 3644 KB
029.txt WA 7 ms 3608 KB
030.txt WA 10 ms 3428 KB
031.txt WA 10 ms 3512 KB
032.txt WA 15 ms 3608 KB
033.txt WA 6 ms 3612 KB
034.txt WA 10 ms 3624 KB
035.txt AC 10 ms 3620 KB
036.txt WA 6 ms 3452 KB
037.txt WA 10 ms 3508 KB
038.txt WA 10 ms 3444 KB
039.txt WA 7 ms 3612 KB
040.txt WA 5 ms 3588 KB
041.txt WA 7 ms 3616 KB
042.txt WA 6 ms 3612 KB
043.txt WA 7 ms 3508 KB
044.txt WA 6 ms 3440 KB
045.txt WA 11 ms 3504 KB
example0.txt AC 2 ms 3604 KB
example1.txt AC 2 ms 3504 KB
example2.txt AC 3 ms 3524 KB