結果
| 問題 |
No.110 しましまピラミッド
|
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2015-08-04 22:56:00 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 2,106 bytes |
| コンパイル時間 | 680 ms |
| コンパイル使用メモリ | 75,164 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-31 11:11:42 |
| 合計ジャッジ時間 | 1,545 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%d",&nw);
| ~~~~~^~~~~~~~~~
main.cpp:30:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
30 | for(int i=0;i<nw;i++) scanf("%d",&w[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp:32:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | scanf("%d",&nb);
| ~~~~~^~~~~~~~~~
main.cpp:34:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
34 | for(int i=0;i<nb;i++) scanf("%d",&b[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
typedef long long ll;
using namespace std;
#define mod 1000000009
#define INF 10000000
#define LLINF 2000000000000000000LL
#define SIZE 101
int main(){
int nw,nb,w[10],b[10],answ=0,ansb=0,top_l,wnum,bnum;
bool f;
scanf("%d",&nw);
for(int i=0;i<nw;i++) scanf("%d",&w[i]);
scanf("%d",&nb);
for(int i=0;i<nb;i++) scanf("%d",&b[i]);
sort(w,w+nw);
sort(b,b+nb);
reverse(w,w+nw);
reverse(b,b+nb);
top_l = w[0];
wnum=1;
bnum=0;
f = false;
while(1){
for(int i=bnum;;i++){
if(i==nb){
f = true;
break;
}
if(top_l > b[i]){
top_l=b[i];
bnum=i+1;
break;
}
}
if(f) break;
answ++;
for(int i=wnum;;i++){
if(i==nw){
f = true;
break;
}
if(top_l > w[i]){
top_l=w[i];
wnum=i+1;
break;
}
}
if(f) break;
answ++;
}
top_l = b[0];
wnum=0;
bnum=1;
f = false;
while(1){
for(int i=wnum;;i++){
if(i==nw){
f = true;
break;
}
if(top_l > w[i]){
top_l=w[i];
wnum=i+1;
break;
}
}
if(f) break;
ansb++;
for(int i=bnum;;i++){
if(i==nb){
f = true;
break;
}
if(top_l > b[i]){
top_l=b[i];
bnum=i+1;
break;
}
}
if(f) break;
ansb++;
}
printf("%d\n",max(answ,ansb)+1);
return 0;
}
goodbaton