# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
758169 |
2023-06-14T08:33:39 Z |
vjudge1 |
Money (IZhO17_money) |
C++14 |
|
15 ms |
15992 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&&!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 |
8 ms |
15956 KB |
Output is correct |
2 |
Correct |
10 ms |
15964 KB |
Output is correct |
3 |
Correct |
9 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15956 KB |
Output is correct |
5 |
Correct |
8 ms |
15904 KB |
Output is correct |
6 |
Correct |
11 ms |
15956 KB |
Output is correct |
7 |
Correct |
9 ms |
15956 KB |
Output is correct |
8 |
Correct |
15 ms |
15992 KB |
Output is correct |
9 |
Correct |
9 ms |
15956 KB |
Output is correct |
10 |
Correct |
14 ms |
15956 KB |
Output is correct |
11 |
Correct |
9 ms |
15956 KB |
Output is correct |
12 |
Incorrect |
10 ms |
15892 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
15956 KB |
Output is correct |
2 |
Correct |
10 ms |
15964 KB |
Output is correct |
3 |
Correct |
9 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15956 KB |
Output is correct |
5 |
Correct |
8 ms |
15904 KB |
Output is correct |
6 |
Correct |
11 ms |
15956 KB |
Output is correct |
7 |
Correct |
9 ms |
15956 KB |
Output is correct |
8 |
Correct |
15 ms |
15992 KB |
Output is correct |
9 |
Correct |
9 ms |
15956 KB |
Output is correct |
10 |
Correct |
14 ms |
15956 KB |
Output is correct |
11 |
Correct |
9 ms |
15956 KB |
Output is correct |
12 |
Incorrect |
10 ms |
15892 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
15956 KB |
Output is correct |
2 |
Correct |
10 ms |
15964 KB |
Output is correct |
3 |
Correct |
9 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15956 KB |
Output is correct |
5 |
Correct |
8 ms |
15904 KB |
Output is correct |
6 |
Correct |
11 ms |
15956 KB |
Output is correct |
7 |
Correct |
9 ms |
15956 KB |
Output is correct |
8 |
Correct |
15 ms |
15992 KB |
Output is correct |
9 |
Correct |
9 ms |
15956 KB |
Output is correct |
10 |
Correct |
14 ms |
15956 KB |
Output is correct |
11 |
Correct |
9 ms |
15956 KB |
Output is correct |
12 |
Incorrect |
10 ms |
15892 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
15956 KB |
Output is correct |
2 |
Correct |
10 ms |
15964 KB |
Output is correct |
3 |
Correct |
9 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15956 KB |
Output is correct |
5 |
Correct |
8 ms |
15904 KB |
Output is correct |
6 |
Correct |
11 ms |
15956 KB |
Output is correct |
7 |
Correct |
9 ms |
15956 KB |
Output is correct |
8 |
Correct |
15 ms |
15992 KB |
Output is correct |
9 |
Correct |
9 ms |
15956 KB |
Output is correct |
10 |
Correct |
14 ms |
15956 KB |
Output is correct |
11 |
Correct |
9 ms |
15956 KB |
Output is correct |
12 |
Incorrect |
10 ms |
15892 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |