Monday, July 21, 2014

Codeforces Round #228 (Div. 2), problem: (C) Fox and Box Accumulation solution

Codeforces Round #228 (Div. 2), problem: (C) Fox and Box Accumulation: http://codeforces.com/contest/389/problem/C

Codeforces Round #228 (Div. 2), problem: (C) Fox and Box Accumulation editorial: http://codeforces.com/blog/entry/10629

Codeforces Round #228 (Div. 2), problem: (C) Fox and Box Accumulation solution: http://ideone.com/AJ4sh5


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int n, x[105], pl=0, cnt=0, b[105]={0};
    vector <int> v;
    scanf("%d", &n);
    for(int i=0; i<n; i++) scanf("%d", &x[i]);
    sort(x, x+n); 
    while(cnt<n) {
        pl++;
        for(int i=0; i<n; i++) if(x[i]>=v.size() && b[i]==0) v.push_back(x[i]), b[i]=1, cnt++;
        v.clear();
    }
    printf("%d", pl);
    return 0;
}


No comments:

Post a Comment