Submission #84335

# Submission time Handle Problem Language Result Execution time Memory
84335 2018-11-14T11:59:38 Z zoooma13 Baloni (COCI15_baloni) C++14
40 / 100
2000 ms 132096 KB
#include <bits/stdc++.h>
using namespace std;

#define MAX_N 1000006

int GIR; char GIC;
inline int GI() {
	GIR = 0 ,GIC = getchar();
	while(GIC < '0' || '9' < GIC)
		GIC = getchar();
	while('0' <= GIC && GIC <= '9') {
		GIR = (GIR * 10) + (GIC - '0');
		GIC = getchar();
	}
	return GIR;
}

int N ,A;
set <int> ss[MAX_N];
multiset <int> ms;

int main()
{
    N = GI(); assert(N < MAX_N);
    for(int i=0; i<N; i++)
    {
        A = GI();
        ss[A].insert(i);
        ms.insert(A);
    }

    int Ans = 0;

    set<int>::iterator it;
    while(!ms.empty())
    {
        int i = *prev(ms.end());
        int j = -1;

        while(true)
        {
            it = ss[i].upper_bound(j);
            if(it == ss[i].end())
                break;

            j = *it;
            ss[i].erase(it);
            ms.erase(ms.find(i--));
        }

        Ans++;
    }

    cout << Ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 47 ms 47324 KB Output is correct
2 Correct 45 ms 47484 KB Output is correct
3 Correct 47 ms 47816 KB Output is correct
4 Correct 47 ms 48020 KB Output is correct
5 Execution timed out 2055 ms 125512 KB Time limit exceeded
6 Execution timed out 2071 ms 132096 KB Time limit exceeded
7 Execution timed out 2075 ms 132096 KB Time limit exceeded
8 Execution timed out 2065 ms 132096 KB Time limit exceeded
9 Execution timed out 2074 ms 132096 KB Time limit exceeded
10 Execution timed out 2077 ms 132096 KB Time limit exceeded