This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int N;
cin >> N;
vector<int> a(N);
for (int i=0;i<N;i++) cin >> a[i];
sort(a.begin(), a.end());
vector<int> max_teams(N);
if (a[0] == 1) max_teams[0] = 1; else max_teams[0] = 0;
for (int i=1;i<N;i++){
max_teams[i] = max_teams[i-1];
if (i + 1 - a[i] == 0) max_teams[i] = max(max_teams[i], 1);
if (i + 1 - a[i] > 0) max_teams[i] = max(max_teams[i], 1 + max_teams[i-a[i]]);
}
cout << max_teams[N-1] << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |