結果
問題 | No.1225 I hate I hate Matrix Construction |
ユーザー |
|
提出日時 | 2020-09-12 18:29:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 767 bytes |
コンパイル時間 | 5,793 ms |
コンパイル使用メモリ | 191,336 KB |
最終ジャッジ日時 | 2025-01-14 13:40:27 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
コンパイルメッセージ
main.cpp:16:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 16 | main() { | ^~~~
ソースコード
#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; }