Submission #446831

# Submission time Handle Problem Language Result Execution time Memory
446831 2021-07-23T12:12:42 Z Nima_Naderi Teams (CEOI11_tea) C++14
0 / 100
174 ms 30616 KB
//In the name of God
//#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const ll MXN = 1e6 + 10;
const ll INF = 1e9;
ll n;
ll A[MXN], dp[MXN], pd[MXN];
int main(){
	ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i ++) cin >> A[i];
	sort(A + 1, A + n + 1, greater<ll>());
	ll ans = 0;
	for(int i = 1; i <= n; i ++){
		ll rem = A[i];
		if(n - i + 1 < rem) continue;
		ans ++;
		i = i + rem - 1;
	}
	reverse(A + 1, A + n + 1);
	for(int i = 1; i <= n; i ++){
		if(A[i] > i){
			dp[i] = dp[i - 1];
			pd[i] = -INF;
			continue;
		}
		pd[i] = dp[i - A[i]] + 1;
		dp[i] = max(pd[i], dp[i - 1]);
	}
	cout << pd[n] << '\n';
	ans = min(ans, dp[n]);
	//cout << ans << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 324 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 332 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 2580 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2892 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 118 ms 21516 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 168 ms 29648 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 174 ms 30616 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -