結果
問題 | No.1708 Quality of Contest |
ユーザー | atjh16 |
提出日時 | 2021-10-17 11:48:44 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 337 ms / 2,000 ms |
コード長 | 1,342 bytes |
コンパイル時間 | 2,294 ms |
コンパイル使用メモリ | 214,968 KB |
実行使用メモリ | 20,528 KB |
最終ジャッジ日時 | 2024-09-17 19:39:05 |
合計ジャッジ時間 | 8,893 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
10,408 KB |
testcase_01 | AC | 4 ms
10,056 KB |
testcase_02 | AC | 4 ms
10,308 KB |
testcase_03 | AC | 8 ms
9,920 KB |
testcase_04 | AC | 9 ms
11,028 KB |
testcase_05 | AC | 8 ms
10,056 KB |
testcase_06 | AC | 8 ms
9,668 KB |
testcase_07 | AC | 8 ms
10,056 KB |
testcase_08 | AC | 4 ms
10,200 KB |
testcase_09 | AC | 290 ms
20,528 KB |
testcase_10 | AC | 223 ms
12,708 KB |
testcase_11 | AC | 297 ms
16,652 KB |
testcase_12 | AC | 315 ms
17,532 KB |
testcase_13 | AC | 278 ms
16,040 KB |
testcase_14 | AC | 305 ms
17,848 KB |
testcase_15 | AC | 333 ms
18,344 KB |
testcase_16 | AC | 321 ms
19,092 KB |
testcase_17 | AC | 289 ms
16,760 KB |
testcase_18 | AC | 300 ms
16,864 KB |
testcase_19 | AC | 304 ms
17,480 KB |
testcase_20 | AC | 295 ms
16,568 KB |
testcase_21 | AC | 328 ms
18,040 KB |
testcase_22 | AC | 324 ms
17,700 KB |
testcase_23 | AC | 337 ms
18,180 KB |
testcase_24 | AC | 229 ms
13,508 KB |
testcase_25 | AC | 230 ms
13,404 KB |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:64, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/functional:62, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:71, from main.cpp:1: In member function 'void std::vector<_Tp, _Alloc>::pop_back() [with _Tp = long long int; _Alloc = std::allocator<long long int>]', inlined from 'int main()' at main.cpp:83:19: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h:1320:9: warning: 'q2' may be used uninitialized [-Wmaybe-uninitialized] 1320 | --this->_M_impl._M_finish; | ^~ main.cpp: In function 'int main()': main.cpp:47:31: note: 'q2' was declared here 47 | int w = 1, y = 0, q1, q2; | ^~ In member function 'void std::vector<_Tp, _Alloc>::pop_back() [with _Tp = long long int; _Alloc = std::allocator<long long int>]', inlined from 'int main()' at main.cpp:70:19: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h:1320:9: warning: 'q1' may be used uninitialized [-Wmaybe-uninitialized] 1320 | --this->_M_impl._M_finish; | ^~ main.cpp: In function 'int main()': main.cpp:47:27: note: 'q1' was declared here 47 | int w = 1, y = 0, q1, q2; | ^~
ソースコード
#include <bits/stdc++.h> using namespace std; int n, k; long long m, x, s, t, z = 0; vector<long long> a[200000]; long long c[200000], d[200001]; priority_queue<pair<long long, int>> Q1, Q2; int main() { cin >> n >> m >> x; for (int i = 0; i < n; i++) { cin >> s >> t; t--; a[t].push_back(s); } for (int i = 0; i < m; i++) { if (a[i].size() > 0) { sort(a[i].begin(), a[i].end()); Q2.push({ a[i].back(), i }); a[i].pop_back(); } } cin >> k; for (int i = 0; i < k; i++) cin >> c[i]; sort(c, c + k); int j = 0, u = k; for (int i = 0; i < k; i++) { while (j <= c[i]) { d[j] = u; j++; } u--; } long long p1 = 0, p2 = 0, z1 = -1, z2 = -1; int w = 1, y = 0, q1, q2; while (w <= c[k - 1]) { if (!Q1.empty()) { p1 = Q1.top().first; q1 = Q1.top().second; Q1.pop(); z1 = p1; } if (!Q2.empty()) { p2 = Q2.top().first; q2 = Q2.top().second; Q2.pop(); z2 = p2 + x; } if (z1 >= z2) { z += z1 * d[w]; z1 = 0; if (a[q1].size() > 0) { Q1.push({ a[q1].back(), q1 }); a[q1].pop_back(); } if(z2 > 0) Q2.push({ p2, q2 }); } else { z += z2 * d[w]; y++; z2 = 0; if (a[q2].size() > 0) { Q1.push({ a[q2].back(), q2 }); a[q2].pop_back(); } if(z1 > 0) Q1.push({ p1, q1 }); } w++; } cout << z << endl; }