AtCoder Beginner Contest 052

Submission #1588733

Source codeソースコード

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
        ll N, a, b;
        cin>>N>>a>>b;
        vector <ll> x;
        for(ll i=0;i<N;i++){
                ll xx;
                cin>>xx;
                x.push_back(xx);
        }
        ll res=0;
        ll now=0, now2=N-1;
        bool def=false;
        while(now!=now2){
                if(!def&&a*abs(x[now+1]-x[now])<b){
                        res+=abs(x[now+1]-x[now]);
                        now++;
                }
                else if(def&&a*abs(x[now2]-x[now2-1])<b){
                        res+=abs(x[now2]-x[now2-1]);
                        now2--;
                }
                else{
                        res+=b;
                        if(def){
                                def=false;
                                now++;
                        }
                        else{
                                def=true;
                                now2--;
                        }
                }
                //cout<<now<<":"<<now2<<endl;
        }
        cout<<res<<endl;
        return 0;
}

Submission

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

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt
All 0 / 500 sample_01.txt,sample_02.txt,sample_03.txt,subtask_1_balancedmax_01.txt,subtask_1_balancedmax_02.txt,subtask_1_max_01.txt,subtask_1_max_02.txt,subtask_1_min_01.txt,subtask_1_onlya_01.txt,subtask_1_onlyamax_01.txt,subtask_1_onlyb_01.txt,subtask_1_onlybmax_01.txt,subtask_1_rand_01.txt,subtask_1_rand_02.txt,subtask_1_rand_03.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_balancedmax_01.txt WA
subtask_1_balancedmax_02.txt WA
subtask_1_max_01.txt WA
subtask_1_max_02.txt WA
subtask_1_min_01.txt AC 1 ms 256 KB
subtask_1_onlya_01.txt WA
subtask_1_onlyamax_01.txt WA
subtask_1_onlyb_01.txt AC 11 ms 640 KB
subtask_1_onlybmax_01.txt AC 42 ms 1400 KB
subtask_1_rand_01.txt AC 26 ms 892 KB
subtask_1_rand_02.txt WA
subtask_1_rand_03.txt WA