# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
554683 |
2022-04-29T07:26:01 Z |
new_acc |
Baloni (COCI15_baloni) |
C++14 |
|
233 ms |
35588 KB |
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e6+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e13;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
int t[N];
vi naj[N];
bitset<N>vis;
void solve(){
int n;
cin>>n;
for(int i=1;i<=n;i++) cin>>t[i];
for(int i=n;i>=1;i--) naj[t[i]].push_back(i);
int res=0;
for(int i=1;i<=n;i++){
if(!vis[i]){
res++;
naj[t[i]].pop_back();
}
vis[i]=1;
if(naj[t[i]-1].size()) vis[naj[t[i]-1][naj[t[i]-1].size()-1]]=1,naj[t[i]-1].pop_back();
}
cout<<res<<"\n";
}
int main(){
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
23764 KB |
Output is correct |
2 |
Correct |
13 ms |
23808 KB |
Output is correct |
3 |
Correct |
13 ms |
23872 KB |
Output is correct |
4 |
Correct |
16 ms |
23892 KB |
Output is correct |
5 |
Correct |
233 ms |
35340 KB |
Output is correct |
6 |
Correct |
214 ms |
35588 KB |
Output is correct |
7 |
Correct |
182 ms |
34756 KB |
Output is correct |
8 |
Correct |
203 ms |
33084 KB |
Output is correct |
9 |
Correct |
218 ms |
35348 KB |
Output is correct |
10 |
Correct |
206 ms |
34472 KB |
Output is correct |