結果

問題 No.1734 Decreasing Elements
ユーザー platinum
提出日時 2021-08-19 08:50:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 806 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 203,360 KB
最終ジャッジ日時 2025-01-23 23:00:10
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

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;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	vector<int> B = A;
	sort(B.begin(), B.end());
	B.erase(unique(B.begin(), B.end()), B.end());
	int siz = B.size();
	if(B[0] == 0) siz--;
	vector<int> C = A;
	sort(C.begin(), C.end());
	if(C == A){
		cout << siz << endl;
		return 0;
	}
	sort(C.begin(), C.end(), greater<int>());
	if(C == A){
		cout << siz << endl;
		return 0;
	}
	int ans = 0;
	rep(i,N){
		int a = A[i];
		if(a == 0) continue;
		ans++;
		for(int j = i; j < N; j++){
			if(A[j] >= a) A[j] -= a;
		}
	}
	cout << ans << endl;

	return 0;
}
0