結果
| 問題 |
No.9 モンスターのレベル上げ
|
| ユーザー |
myanta
|
| 提出日時 | 2017-04-30 20:45:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 840 bytes |
| コンパイル時間 | 684 ms |
| コンパイル使用メモリ | 49,664 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-13 23:57:28 |
| 合計ジャッジ時間 | 3,788 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 14 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:45:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
45 | scanf("%d", &a[i]);
| ~~~~~^~~~~~~~~~~~~
main.cpp:49:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
49 | scanf("%d", &b[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
struct p_t
{
int l, x;
bool operator<(const p_t& rhs) const
{
if(l!=rhs.l) return (l>rhs.l);
return (x>rhs.x);
}
};
int max_u(int& m, int v)
{
if(m<v)
{
m=v;
return 1;
}
return 0;
}
int main(void)
{
int n, i, j;
vector<int> a;
vector<int> b;
int max;
while(scanf("%d", &n)==1)
{
a.resize(n);
b.resize(n);
for(i=0;i<n;i++)
{
scanf("%d", &a[i]);
}
for(i=0;i<n;i++)
{
scanf("%d", &b[i]);
b[i]/=2;
}
max=0;
for(i=0;i<n;i++)
{
priority_queue<p_t, vector<p_t> > q;
p_t p;
for(j=0;j<n;j++) q.push((p_t){a[j], 0});
for(j=0;j<n;j++)
{
p=q.top();
q.pop();
p.l+=b[(i+j)%n];
p.x++;
q.push(p);
max_u(max, p.x);
}
}
printf("%d\n", max);
}
return 0;
}
myanta