結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー 37zigen37zigen
提出日時 2020-09-12 18:29:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 198,028 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 17:58:26
合計ジャッジ時間 3,894 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:16:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   16 | main() {
      | ^~~~

ソースコード

diff #

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

// s0 : 全て0
// s1 : 1 が一つ以上ある
// s2 : 全て1


int f(int H,int W,int s0,int s1,int s2,int t0,int t1,int t2) {
    if (s2>0) return f(H-s2,W,s0,s1,0,t0,0,t2)+W*s2;
    if (t2>0) return f(W,H,t0,t1,t2,s0,s1,s2);
    if (s0>0||t0>0) return f(H-t0,W-s0,0,s1,s2,0,t1,t2);
    return max(s1,t1);
}

main() {
    int N;
    cin>>N;
    int s0=0,s1=0,s2=0,t0=0,t1=0,t2=0;
    for (int i=0;i<N;++i) {
        int s;cin>>s;
        if (s==0) ++s0;
        else if (s==1) ++s1;
        else if (s==2) ++s2;
    }
    for (int i=0;i<N;++i) {
        int t;cin>>t;
        if (t==0) ++t0;
        else if (t==1) ++t1;
        else if (t==2) ++t2;
    }
    int ans=f(N,N,s0,s1,s2,t0,t1,t2);
    cout<<ans<<endl;
}
0