結果
| 問題 |
No.110 しましまピラミッド
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2014-12-23 23:27:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 821 bytes |
| コンパイル時間 | 329 ms |
| コンパイル使用メモリ | 51,248 KB |
| 最終ジャッジ日時 | 2024-11-14 18:57:37 |
| 合計ジャッジ時間 | 945 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:5:16: error: ‘vector’ does not name a type
5 | int func(const vector<int>& a, const vector<int>& b)
| ^~~~~~
main.cpp:5:22: error: expected ‘,’ or ‘...’ before ‘<’ token
5 | int func(const vector<int>& a, const vector<int>& b)
| ^
main.cpp: In function ‘int func(int)’:
main.cpp:7:11: error: ‘a’ was not declared in this scope
7 | int n=a.size(), m=b.size();
| ^
main.cpp:12:36: error: ‘b’ was not declared in this scope; did you mean ‘bi’?
12 | while (ai<n and a[ai]>=b[bi]) ++ai;
| ^
| bi
main.cpp:17:23: error: ‘m’ was not declared in this scope
17 | while (bi<m and b[bi]>=a[ai]) ++bi;
| ^
main.cpp:17:29: error: ‘b’ was not declared in this scope; did you mean ‘bi’?
17 | while (bi<m and b[bi]>=a[ai]) ++bi;
| ^
| bi
main.cpp:18:21: error: ‘m’ was not declared in this scope
18 | if (bi==m) break;
| ^
main.cpp: In function ‘int main()’:
main.cpp:29:5: error: ‘vector’ was not declared in this scope
29 | vector<int> w(n);
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:29:12: error: expected primary-expression before ‘int’
29 | vector<int> w(n);
| ^~~
main.cpp:30:17: error: ‘w’ was not declared in this scope
30 | for(int& v: w) cin>>v;
| ^
main.cpp:31:16: error: ‘w’ was not declared in this scope
31 | sort(begin(w), end(w));
| ^
main.cpp:35:12: error: expected primary-expression before ‘int’
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int func(const vector<int>& a, const vector<int>& b)
{
int n=a.size(), m=b.size();
int f=0, ai=0, bi=0;
int res=1, len=a[ai];
while (true) {
if (f) {
while (ai<n and a[ai]>=b[bi]) ++ai;
if (ai==n) break;
++res;
}
else {
while (bi<m and b[bi]>=a[ai]) ++bi;
if (bi==m) break;
++res;
}
f^=1;
}
return res;
}
int main()
{
int n; cin>>n;
vector<int> w(n);
for(int& v: w) cin>>v;
sort(begin(w), end(w));
reverse(begin(w), end(w));
int m; cin>>m;
vector<int> b(m);
for(int& v: b) cin>>v;
sort(begin(b), end(b));
reverse(begin(b), end(b));
cout<<max(func(w, b), func(b, w))<<endl;
}
hogeover30