結果

問題 No.1734 Decreasing Elements
ユーザー 👑 platinumplatinum
提出日時 2021-08-17 14:18:17
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 836 bytes
コンパイル時間 2,329 ms
コンパイル使用メモリ 212,380 KB
実行使用メモリ 15,716 KB
最終ジャッジ日時 2023-08-06 08:50:55
合計ジャッジ時間 7,752 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 76 ms
14,000 KB
testcase_08 AC 81 ms
13,976 KB
testcase_09 AC 80 ms
13,768 KB
testcase_10 AC 82 ms
14,004 KB
testcase_11 AC 125 ms
14,476 KB
testcase_12 AC 85 ms
10,368 KB
testcase_13 AC 120 ms
14,080 KB
testcase_14 WA -
testcase_15 AC 154 ms
14,532 KB
testcase_16 WA -
testcase_17 AC 211 ms
14,584 KB
testcase_18 AC 217 ms
14,864 KB
testcase_19 AC 168 ms
14,860 KB
testcase_20 WA -
testcase_21 AC 159 ms
13,252 KB
testcase_22 AC 171 ms
14,976 KB
testcase_23 WA -
testcase_24 AC 177 ms
14,784 KB
testcase_25 WA -
testcase_26 AC 186 ms
15,396 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