Submission #446830

#TimeUsernameProblemLanguageResultExecution timeMemory
446830Nima_NaderiTraffic (CEOI11_tra)C++14
0 / 100
68 ms10352 KiB
//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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...