Submission #684226

#TimeUsernameProblemLanguageResultExecution timeMemory
684226sudheerays123Po (COCI21_po)C++17
20 / 70
52 ms15140 KiB
#include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ll long long int const ll N = 1e5+5 , INF = 1e18 , MOD = 1e9+7; vector<ll> seg(4*N); vector<ll> a(N); void build(ll node , ll left , ll right){ if(left == right){ seg[node] = a[left]; return; } ll mid = (left+right)/2; build(2*node,left,mid); build(2*node+1,mid+1,right); seg[node] = min(seg[2*node],seg[2*node+1]); } ll query(ll node , ll left , ll right , ll ql , ll qr){ if(left >= ql && right <= qr) return seg[node]; if(left > qr || right < ql) return INF; ll mid = (left+right)/2; ll l = query(2*node,left,mid,ql,qr); ll r = query(2*node+1,mid+1,right,ql,qr); return min(l,r); } void solve(){ ll n; cin >> n; map<ll,vector<ll>> m; for(ll i = 1; i <= n; i++){ cin >> a[i]; m[a[i]].push_back(i); } build(1,1,n); ll ans = n; for(auto u : m){ vector<ll> ind = u.second; for(ll i = 1; i < ind.size();i++) if(query(1,1,n,ind[i-1],ind[i]) >= u.first) ans--; } cout << ans; } int main(){ fast; ll tc = 1; // cin >> tc; while(tc--) solve(); return 0; }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:56:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   for(ll i = 1; i < ind.size();i++)
      |                 ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...