結果

問題 No.1734 Decreasing Elements
ユーザー 👑 platinumplatinum
提出日時 2021-08-17 14:18:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 836 bytes
コンパイル時間 2,543 ms
コンパイル使用メモリ 207,000 KB
実行使用メモリ 15,676 KB
最終ジャッジ日時 2024-04-24 04:50:49
合計ジャッジ時間 7,818 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
5,376 KB
testcase_07 AC 88 ms
14,276 KB
testcase_08 AC 92 ms
14,136 KB
testcase_09 AC 89 ms
14,404 KB
testcase_10 AC 90 ms
14,156 KB
testcase_11 AC 143 ms
14,688 KB
testcase_12 AC 96 ms
10,564 KB
testcase_13 AC 140 ms
14,140 KB
testcase_14 WA -
testcase_15 AC 199 ms
14,720 KB
testcase_16 WA -
testcase_17 AC 272 ms
15,044 KB
testcase_18 AC 278 ms
15,000 KB
testcase_19 AC 173 ms
14,992 KB
testcase_20 WA -
testcase_21 AC 171 ms
13,400 KB
testcase_22 AC 184 ms
15,192 KB
testcase_23 WA -
testcase_24 AC 195 ms
15,072 KB
testcase_25 WA -
testcase_26 AC 206 ms
15,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;
using vv = vector<vector<int>>;
const int INF = (int)1e9;
const LL LINF = (LL)1e18;
const int A_Max = (int)2e5;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	priority_queue<P> q;
	set<int> st;
	st.insert(0);
	q.push(P(A_Max, 0));
	int ans = N;
	rep(i,N){
		auto itr = st.upper_bound(A[i]);
		itr--;
		int a = A[i] - *itr;
		if(a == 0){
			ans--;
			continue;
		}
		int siz = q.size();
		vector<P> res;
		rep(j,siz){
			P p = q.top();
			if(p.first <= a) break;
			q.pop();
			res.emplace_back(a, p.second);
			res.emplace_back(p.first - a, p.second + a);
			st.insert(p.second + a);
		}
		rep(j,res.size()) q.push(res[j]);
	}
	cout << ans << endl;

	return 0;
}
0