結果
| 問題 |
No.231 めぐるはめぐる (1)
|
| コンテスト | |
| ユーザー |
rsk0315
|
| 提出日時 | 2019-01-20 00:38:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 774 bytes |
| コンパイル時間 | 532 ms |
| コンパイル使用メモリ | 63,312 KB |
| 最終ジャッジ日時 | 2025-01-06 20:30:29 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%zu", &N);
| ~~~~~^~~~~~~~~~~
main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d %d", &G, &D);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
int hoge(const std::vector<std::pair<int, int>>& X) {
int res = 0;
for (size_t i = 0; i < 6; ++i)
res += X[i%X.size()].first;
return res;
}
int main() {
size_t N;
scanf("%zu", &N);
std::vector<std::pair<int, int>> X(N);
for (size_t i = 0; i < N; ++i) {
int G, D;
scanf("%d %d", &G, &D);
X[i] = {G - 30000*D, i+1};
}
std::sort(X.rbegin(), X.rend());
if (N > 6) X.resize(6);
const int REQ = 30000*100;
if (X[0].first*6 < REQ)
return puts("NO"), 0;
puts("YES");
for (size_t i = X.size(); i--;) {
if (hoge(X) >= REQ) {
for (size_t j = 0; j < 6; ++j)
printf("%d\n", X[j%X.size()].second);
break;
}
X.pop_back();
}
}
rsk0315