# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
869979 | 2023-11-06T13:13:44 Z | MercubytheFirst | Baloni (COCI15_baloni) | C++17 | 75 ms | 40276 KB |
/* */ #include<iostream> #include<vector> #include<iomanip> #include<algorithm> #include<map> #include<set> #include<climits> #include<numeric> #include<queue> #include<unordered_map> #include<string> #include<climits> #include<unordered_set> #include<bitset> #include<cstring> #include<cmath> #include<stack> #include<tuple> #include<complex> #if 1 #define pb push_back #define endl '\n' #define fi first #define se second #define fio ios_base::sync_with_stdio(false);cin.tie(NULL); #define CDIV(a,b) (((a)+(b)-(1))/(b)) using namespace std; using ll = long long; using ld = long double; const ll inf = 1e9 + 5; const ll mod = 998244353; const ll N = 1e6 + 4; const ld PI = acos((ld)-1); #endif void fileio(string s = "test"){ #ifndef ONLINE_JUDGE freopen((s+string(".in")).c_str(),"r",stdin); freopen((s+string(".out")).c_str(),"w",stdout); #endif } ll bpow(ll a, ll p) { if(a == 0 or a == 1)return a; ll ans = 1; while(p) { if(p&1)ans = ans * a % mod; a = a * a % mod; p >>= 1; } return ans; } ll add(ll a, ll b){ if(a + b >= mod) return a + b - mod; return a + b; } ll sub(ll a, ll b){ if(a - b >= 0) return a - b; return a - b + mod; } ll mul(ll a, ll b){ return (a%mod)*(b%mod)%mod; } ll digitSum(ll n){ ll sum = 0; while(n){ sum += n % 10; n /= 10; } return sum; } inline void solve(){ ll n; cin >> n; vector<ll> v(n + 1); vector<vector<ll> >keep(N); for(ll i = 1; i <= n; ++i){ cin >> v[i]; } for(ll i = n; i >= 1; --i){ keep[v[i]].pb(i); } ll ans = 0; for(ll i = 1; i <= n; ++i){ if(v[i] == -1) continue; ll cur = v[i]; int lasti = i; ans++; while(cur >= 1 and !keep[cur].empty()){ if(keep[cur].back() < lasti) break; lasti = keep[cur].back(); v[keep[cur].back()] = -1; keep[cur].pop_back(); cur--; } } cout << ans << endl; } signed main(){ //fileio(); fio; // int t = 0;cin >> t;while(t-->0) solve(); } /* 2 9 9 3 1 1 3 8 8 8 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 23896 KB | Output isn't correct |
2 | Incorrect | 7 ms | 23900 KB | Output isn't correct |
3 | Incorrect | 7 ms | 23964 KB | Output isn't correct |
4 | Incorrect | 7 ms | 23900 KB | Output isn't correct |
5 | Incorrect | 75 ms | 39352 KB | Output isn't correct |
6 | Incorrect | 65 ms | 40016 KB | Output isn't correct |
7 | Incorrect | 54 ms | 38992 KB | Output isn't correct |
8 | Incorrect | 52 ms | 36688 KB | Output isn't correct |
9 | Incorrect | 59 ms | 40276 KB | Output isn't correct |
10 | Incorrect | 60 ms | 38704 KB | Output isn't correct |