Typical DP Contest

Submission #5885196

Source codeソースコード

#include<bits/stdc++.h>
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    vector<int> sunuke(A), sumeke(B);
    sunuke[0] = 0;
    sumeke[0] = 0;
    for(int i= 1 ; i <= A; i++){
        int tmp; cin >> tmp;
        sunuke[i] = tmp;
    }
    for(int i = 1; i <= B; i++){
        int tmp; cin >> tmp;
        sumeke[i] = tmp;
    }
    int pointa = A, pointb = B;

    bool s = (A + B) % 2;
    int sumu = 0, sume = 0;
    while(pointa > 0 || pointb > 0){
        if(s){
            if(sunuke[pointa] > sumeke[pointb]){
                sumu += sunuke[pointa];
                pointa--;
            }else if(sunuke[pointa] < sumeke[pointb]){
                sumu += sumeke[pointb];
                pointb--;
            }else{
                if(sunuke[pointa-1] > sumeke[pointb-1]){
                    sumu += sumeke[pointb];
                    pointb--;
                }else{
                    sumu += sunuke[pointa];
                    pointa--;
                }
            }
            s = !s;
        }else{
            if(sunuke[pointa] > sumeke[pointb]){
                sume += sunuke[pointa];
                pointa--;
            }else if(sunuke[pointa] < sumeke[pointb]){
                sume += sumeke[pointb];
                pointb--;
            }else{
                if(sunuke[pointa-1] > sumeke[pointb-1]){
                    sume += sumeke[pointb];
                    pointb--;
                }else{
                    sume += sunuke[pointa];
                    pointa--;
                }
            }
            s = !s;
        }
        //cout <<"point" <<  pointa << " " << pointb << endl;
        //cout << sumu << " " << sume << endl;
    }
    cout << sumu << endl;

}

Submission

Task問題 B - ゲーム
User nameユーザ名 raoZ
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 RE
Score得点 0
Source lengthソースコード長 1792 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
All 0 / 3 00,01,02,90,91

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00 RE
01 RE
02 WA
90 AC 1 ms 256 KB
91 AC 1 ms 256 KB