# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
758145 |
2023-06-14T08:11:23 Z |
vjudge1 |
Money (IZhO17_money) |
C++14 |
|
9 ms |
16092 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;
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++){
bool GG=0;
if(arr[i]==bo){
l=arr[i];
// cout<<l<<' ';
bl[l]++;
}else if(l!=-1&&arr[i]>=l&&bl[arr[i]]<bol[arr[i]]){
bool BO=0;
for(int w=arr[i]-1;w>l;w--){
if(bl[w]){
// cout<<'g'<<w<<' ';
BO=1;
}
}
if(!BO){
l=arr[i];
// cout<<l<<' ';
bl[l]++;
}else GG=1;
}else if(l!=-1)break;
if(GG)break;
}
// cout<<endl;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
15928 KB |
Output is correct |
2 |
Correct |
9 ms |
15956 KB |
Output is correct |
3 |
Correct |
8 ms |
15956 KB |
Output is correct |
4 |
Incorrect |
8 ms |
16092 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
15928 KB |
Output is correct |
2 |
Correct |
9 ms |
15956 KB |
Output is correct |
3 |
Correct |
8 ms |
15956 KB |
Output is correct |
4 |
Incorrect |
8 ms |
16092 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
15928 KB |
Output is correct |
2 |
Correct |
9 ms |
15956 KB |
Output is correct |
3 |
Correct |
8 ms |
15956 KB |
Output is correct |
4 |
Incorrect |
8 ms |
16092 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
15928 KB |
Output is correct |
2 |
Correct |
9 ms |
15956 KB |
Output is correct |
3 |
Correct |
8 ms |
15956 KB |
Output is correct |
4 |
Incorrect |
8 ms |
16092 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |