# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
758164 |
2023-06-14T08:30:52 Z |
vjudge1 |
Money (IZhO17_money) |
C++14 |
|
11 ms |
15984 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;
vector<int>bl(1000001);
vector<int>bol(1000001);
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
bol[arr[i]]++;
}
vector<int>v;
for(auto &i:arr)v.push_back(i);
sort(v.begin(),v.end());
int ans=0;
vector<bool>bll(n);
while(1){
int bo=-1;
for(int i=1;i<1000001;i++){
if(bl[i]<bol[i]){
bo=i;
break;
}
}
if(bo==-1)break;
ans++;
int l=-1;
for(int i=0;i<n;i++){
// cout<<'G'<<arr[i]<<'G';
bool GG=0;
if(l==-1&&arr[i]==bo&&!bll[i]){
l=arr[i];
bll[i]=1;
// cout<<l<<' ';
bl[l]++;
}else if(l!=-1&&arr[i]>=l&&!bll[i]&&bl[arr[i]]<bol[arr[i]]){
bool BO=0;
// cout<<'f'<<arr[i]<<' '<<l<<' '<<'g';
for(int w=arr[i]-1;w>l;w--){
if(bl[w]){
// cout<<'g'<<w<<' ';
BO=1;
}
}
if(!BO){
l=arr[i];
// cout<<'f'<<l<<' ';
bll[i]=1;
bl[l]++;
}else{break;}
}else if(l!=-1)break;
if(GG)break;
}
// cout<<endl;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
15956 KB |
Output is correct |
2 |
Correct |
11 ms |
15956 KB |
Output is correct |
3 |
Correct |
8 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15912 KB |
Output is correct |
5 |
Correct |
9 ms |
15956 KB |
Output is correct |
6 |
Correct |
8 ms |
15956 KB |
Output is correct |
7 |
Correct |
9 ms |
15956 KB |
Output is correct |
8 |
Correct |
11 ms |
15876 KB |
Output is correct |
9 |
Correct |
8 ms |
15984 KB |
Output is correct |
10 |
Incorrect |
10 ms |
15884 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
15956 KB |
Output is correct |
2 |
Correct |
11 ms |
15956 KB |
Output is correct |
3 |
Correct |
8 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15912 KB |
Output is correct |
5 |
Correct |
9 ms |
15956 KB |
Output is correct |
6 |
Correct |
8 ms |
15956 KB |
Output is correct |
7 |
Correct |
9 ms |
15956 KB |
Output is correct |
8 |
Correct |
11 ms |
15876 KB |
Output is correct |
9 |
Correct |
8 ms |
15984 KB |
Output is correct |
10 |
Incorrect |
10 ms |
15884 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
15956 KB |
Output is correct |
2 |
Correct |
11 ms |
15956 KB |
Output is correct |
3 |
Correct |
8 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15912 KB |
Output is correct |
5 |
Correct |
9 ms |
15956 KB |
Output is correct |
6 |
Correct |
8 ms |
15956 KB |
Output is correct |
7 |
Correct |
9 ms |
15956 KB |
Output is correct |
8 |
Correct |
11 ms |
15876 KB |
Output is correct |
9 |
Correct |
8 ms |
15984 KB |
Output is correct |
10 |
Incorrect |
10 ms |
15884 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
15956 KB |
Output is correct |
2 |
Correct |
11 ms |
15956 KB |
Output is correct |
3 |
Correct |
8 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15912 KB |
Output is correct |
5 |
Correct |
9 ms |
15956 KB |
Output is correct |
6 |
Correct |
8 ms |
15956 KB |
Output is correct |
7 |
Correct |
9 ms |
15956 KB |
Output is correct |
8 |
Correct |
11 ms |
15876 KB |
Output is correct |
9 |
Correct |
8 ms |
15984 KB |
Output is correct |
10 |
Incorrect |
10 ms |
15884 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |