Submission #708997

#TimeUsernameProblemLanguageResultExecution timeMemory
708997vjudge1Baloni (COCI15_baloni)C++17
100 / 100
838 ms95940 KiB
#include<bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; #define int long long #define ll long long #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define freopen(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout); const int N = 1e6 + 5; const int M = 3e3 + 5; const ll mod = 1e9 + 7; const ll inf = 1e7; int n, h[N], id, x, ans; set<int> st[N]; main() { fast cin >> n; for(int i = 1; i <= n; i++){ cin >> h[i]; st[h[i]].insert(i); } for(int i = 1000000; i >= 1; i--){ while(st[i].size()){ x = i; id = *st[i].begin(); while(x && st[x].size()){ if(st[x].lower_bound(id) == st[x].end()) break; id = *st[x].lower_bound(id); st[x].erase(id); x--; } ans++; } } cout << ans; }

Compilation message (stderr)

baloni.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization("O3")
      | 
baloni.cpp:4: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    4 | #pragma GCC optimization("unroll-loops")
      | 
baloni.cpp:5: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    5 | #pragma comment(linker, "/stack:200000000")
      | 
baloni.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   27 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...