結果

問題 No.1734 Decreasing Elements
ユーザー 👑 platinumplatinum
提出日時 2021-08-19 08:50:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 806 bytes
コンパイル時間 2,510 ms
コンパイル使用メモリ 203,212 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-24 04:51:51
合計ジャッジ時間 8,581 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 54 ms
5,376 KB
testcase_12 AC 36 ms
5,376 KB
testcase_13 AC 59 ms
5,376 KB
testcase_14 AC 131 ms
5,504 KB
testcase_15 AC 78 ms
5,376 KB
testcase_16 AC 131 ms
5,504 KB
testcase_17 AC 147 ms
5,632 KB
testcase_18 AC 149 ms
5,504 KB
testcase_19 AC 71 ms
5,632 KB
testcase_20 AC 70 ms
5,632 KB
testcase_21 AC 72 ms
5,504 KB
testcase_22 AC 72 ms
5,632 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

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