| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1332813 | Zone_zonee | Baloni (COCI15_baloni) | C++20 | 51 ms | 8664 KiB |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
int a[N], idx[N];
vector<int> q[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
for(int i = 1; i <= n; ++i){
cin >> a[i];
q[a[i]].push_back(i);
}
int ans = 0;
for(int i = 1; i <= n; ++i){
if(idx[a[i]] >= q[a[i]].size() || q[a[i]].front() != i) continue;
while(idx[a[i]] < q[a[i]].size() && q[a[i]].front() >= i) idx[a[i]--]++;
ans++;
}
cout << ans << '\n';
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
