結果

問題 No.9 モンスターのレベル上げ
ユーザー myanta
提出日時 2017-04-30 20:48:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 240 ms / 5,000 ms
コード長 951 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 49,924 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-23 23:56:35
合計ジャッジ時間 3,293 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:56:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   56 |                         scanf("%d", &a[i]);
      |                         ~~~~~^~~~~~~~~~~~~
main.cpp:60:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   60 |                         scanf("%d", &b[i]);
      |                         ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#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 min_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, min;

	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;
		}

		min=n;
		for(i=0;i<n;i++)
		{
			max=0;
			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);
			}
			min_u(min, max);
		}
		printf("%d\n", min);
	}

	return 0;
}
0