結果

問題 No.1199 お菓子配り-2
ユーザー Hydrogen1008Hydrogen1008
提出日時 2020-10-07 19:56:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 386 ms / 1,000 ms
コード長 728 bytes
コンパイル時間 1,913 ms
コンパイル使用メモリ 165,932 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 09:23:14
合計ジャッジ時間 17,332 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 94 ms
4,376 KB
testcase_04 AC 233 ms
4,380 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 14 ms
4,376 KB
testcase_07 AC 118 ms
4,376 KB
testcase_08 AC 154 ms
4,380 KB
testcase_09 AC 95 ms
4,380 KB
testcase_10 AC 24 ms
4,380 KB
testcase_11 AC 73 ms
4,380 KB
testcase_12 AC 77 ms
4,380 KB
testcase_13 AC 25 ms
4,376 KB
testcase_14 AC 21 ms
4,376 KB
testcase_15 AC 17 ms
4,380 KB
testcase_16 AC 150 ms
4,376 KB
testcase_17 AC 69 ms
4,376 KB
testcase_18 AC 164 ms
4,376 KB
testcase_19 AC 43 ms
4,380 KB
testcase_20 AC 280 ms
4,380 KB
testcase_21 AC 169 ms
4,380 KB
testcase_22 AC 91 ms
4,380 KB
testcase_23 AC 126 ms
4,376 KB
testcase_24 AC 173 ms
4,376 KB
testcase_25 AC 27 ms
4,380 KB
testcase_26 AC 199 ms
4,376 KB
testcase_27 AC 159 ms
4,376 KB
testcase_28 AC 383 ms
4,376 KB
testcase_29 AC 363 ms
4,376 KB
testcase_30 AC 386 ms
4,380 KB
testcase_31 AC 363 ms
4,380 KB
testcase_32 AC 366 ms
4,376 KB
testcase_33 AC 373 ms
4,380 KB
testcase_34 AC 372 ms
4,380 KB
testcase_35 AC 376 ms
4,380 KB
testcase_36 AC 367 ms
4,380 KB
testcase_37 AC 367 ms
4,380 KB
testcase_38 AC 381 ms
4,380 KB
testcase_39 AC 366 ms
4,380 KB
testcase_40 AC 365 ms
4,376 KB
testcase_41 AC 365 ms
4,380 KB
testcase_42 AC 365 ms
4,376 KB
testcase_43 AC 369 ms
4,380 KB
testcase_44 AC 372 ms
4,376 KB
testcase_45 AC 367 ms
4,376 KB
testcase_46 AC 363 ms
4,376 KB
testcase_47 AC 370 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


int main() {
    
int N;
int M;
long long int Ans=0LL;
int Eat=0;

cin >> N >> M ;
vector<long long int>Happiness(N+1);
vector<long long int>happy(M);

for(int i=1; i<N+1; i++){
    for(int j=0; j<M; j++){
        cin >> happy.at(j);
        Happiness.at(i)=Happiness.at(i)+happy.at(j);
        happy.at(j)=0LL;
    }
}

for(int i=1; i<N; i++){
    if(Eat%2==0){
        if(Happiness.at(i)>Happiness.at(i+1)){
            Eat++;
            Ans=Ans+Happiness.at(i);
        }
    }
    else{
        if(Happiness.at(i)<Happiness.at(i+1)){
            Eat++;
            Ans=Ans-Happiness.at(i);
        }
    }
}
if(Eat%2==0){
    Ans=Ans+Happiness.at(N);
}



cout << Ans ; 


}
0