結果

問題 No.231 めぐるはめぐる (1)
ユーザー 37kt_37kt_
提出日時 2015-09-03 18:41:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 689 bytes
コンパイル時間 1,577 ms
コンパイル使用メモリ 167,780 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 12:20:12
合計ジャッジ時間 2,052 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%d %d", g + i, d + i);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int n;
int g[1000], d[1000];

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d %d", g + i, d + i);
	}
	
	vector<pair<int, int>> v;
	for (int i = 0; i < n; i++){
		v.push_back(make_pair(g[i] - 30000 * d[i], i));
	}
	sort(begin(v), end(v), greater<pair<int, int>>());
	
	vector<int> res;
	for (int i = 1; i <= min(6, n); i++){
		vector<int> r;
		int e = 0;
		for (int j = 0; j < 6; j++){
			int p = j % i;
			e += v[p].first;
			r.push_back(v[p].second);
		}
		if (e >= 3000000) res = r;
	}
	
	if (res.size() == 0) puts("NO");
	else {
		puts("YES");
		for (int i = 0; i < 6; i++){
			printf("%d\n", res[i] + 1);
		}
	}
}
0