結果

問題 No.1708 Quality of Contest
ユーザー atjh16atjh16
提出日時 2021-10-17 11:23:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,314 bytes
コンパイル時間 2,382 ms
コンパイル使用メモリ 213,672 KB
実行使用メモリ 19,984 KB
最終ジャッジ日時 2024-09-17 19:38:44
合計ジャッジ時間 11,636 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,260 KB
testcase_01 AC 4 ms
8,900 KB
testcase_02 AC 3 ms
8,312 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 4 ms
9,032 KB
testcase_09 AC 293 ms
19,984 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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:78: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:45:31: note: 'q2' was declared here
   45 |         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:67: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:45:27: note: 'q1' was declared here
   45 |         int w = 1, y = 0, q1, q2;
      |                           ^~

ソースコード

diff #

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

int n, k;
long long m, x, s, t, z = 0;
vector<long long> a[200000];
int 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++) {
		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 (!Q1.empty() || !Q2.empty()) {
		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;
}
0