結果
問題 | No.798 コレクション |
ユーザー | 👑 emthrm |
提出日時 | 2019-03-15 22:14:56 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,692 bytes |
コンパイル時間 | 1,425 ms |
コンパイル使用メモリ | 133,380 KB |
実行使用メモリ | 4,504 KB |
最終ジャッジ日時 | 2023-09-14 13:42:47 |
合計ジャッジ時間 | 2,427 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | WA | - |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 1 ms
4,380 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 1 ms
4,376 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 1 ms
4,376 KB |
testcase_24 | AC | 3 ms
4,376 KB |
testcase_25 | AC | 3 ms
4,380 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:56:35: 警告: ‘pos’ may be used uninitialized [-Wmaybe-uninitialized] 56 | swap(kau.back(), kawanai[pos]); | ^ main.cpp:48:9: 備考: ‘pos’ はここで定義されています 48 | int pos; long long mn = LINF; | ^~~
ソースコード
#include <algorithm> #include <cassert> #include <cctype> #include <chrono> #define _USE_MATH_DEFINES #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <string> #include <tuple> #include <vector> using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() const int INF = 0x3f3f3f3f, MOD = 1000000007; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; /*-----------------------------------------*/ int main() { cin.tie(0); ios::sync_with_stdio(false); // freopen("input.txt", "r", stdin); int n; cin >> n; int buy = 0, cnt = 0; while (cnt < n) { ++buy; ++cnt; if (buy % 2 == 0) ++cnt; } vector<pair<int, int> > ba(n); REP(i, n) cin >> ba[i].second >> ba[i].first; sort(ALL(ba)); vector<pair<int, long long> > kau(buy), kawanai(n - buy); REP(i, buy) kau[i] = ba[i]; FOR(i, buy, n) kawanai[i - buy] = ba[i]; long long ans = 0; REP(i, buy) { int pos; long long mn = LINF; REP(j, kawanai.size()) { if (kawanai[j].second <= mn) { pos = j; mn = kawanai[j].second; } } if (kau.back().second > mn) { swap(kau.back(), kawanai[pos]); sort(ALL(kawanai)); } ans += kau.back().second; kau.pop_back(); if (i & 1 && !kawanai.empty()) kawanai.pop_back(); for (auto &e : kau) e.second += e.first; for (auto &e : kawanai) e.second += e.first; } cout << ans << '\n'; return 0; }