제출 #37671

#제출 시각아이디문제언어결과실행 시간메모리
37671AbelyanMoney (IZhO17_money)C++14
0 / 100
0 ms10964 KiB
#include <bits/stdc++.h> using namespace std; const int N=1000006; pair <int,int> a[N]; bool r[N]; int ans=1; void check(int i,int mi){ if (r[a[i].second]){ r[a[mi].second+1]=false; r[a[i].second+1]=true; } else{ if (a[i].second < a[mi].second){ r[a[mi].second + 1] = false; r[a[i].second + 1] = true; } else{ r[a[i].second + 1] = true; } ans++; } } int main(){ ios_base::sync_with_stdio(false); //freopen("money.in","r",stdin); //freopen("money.out","w",stdout); int n,j,h=0; cin>>n; for (int i = 0; i < n; i++){ int k; cin>>k; if (h!=0 & k==a[h-1].first){ continue; } a[h].first=k; a[h].second=h; h++; } n=h; sort(a,a+n); r[a[0].second+1]=true; j=1; while (a[j].first==a[j-1].first){ check(j,j-1); j++; } while(j<n){ //cout<<j<<endl; int l=j; j++; while (a[j].first==a[j-1].first){ j++; } j--; int k=j; bool mb=false; //cout<<r[a[4].second]<<endl; while (r[a[j].second]){ if (j==k){ check(j,l-1); //cout<<"Alex"<<endl; mb=true; } else check(j,j+1); j--; } for (int i=l;i<=j;i++){ if (i==l && mb){ check(i,j+1); } else{ //cout<<"alex"<<endl; check(i,i-1); } } j=k+1; } cout<<ans<<endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

money.cpp: In function 'int main()':
money.cpp:35:8: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   if (h!=0 & k==a[h-1].first){
        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...