# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
684226 | sudheerays123 | Po (COCI21_po) | C++17 | 52 ms | 15140 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |