Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("ciuperci.in");
- struct ciuperci
- {
- int g;
- bool ot;
- }v[5000];
- void Read(int &n, int &L)
- {
- fin>>n>>L;
- for(int i=1; i<=n; i++)
- {
- fin>>v[i].g;
- fin>>v[i].ot;
- }
- // for(int i=1; i<=n; i++)
- // cout<<v[i].g<<" "<<v[i].ot<<endl;
- }
- int DetMax(int k, int L, int &maxx, int n, int &mod)
- {
- if(v[k].ot==1)
- return 0;
- int p=k+1, cnt=1, l;
- cout<<cnt<<" -- "<<maxx<<" -- "<<mod<<endl;
- while(p<=n)
- {
- l=p-k;
- if(v[k].ot==0)
- if(v[k].g < v[p].g && v[p].ot==0 && l <= L)
- {
- cnt++;
- cout<<" |----> "<<v[k].g<<" -- "<<v[p].g<<endl;
- k=p;
- p++;
- }
- else
- p++;
- else
- {
- k++;
- p++;
- }
- }
- if(cnt > maxx)
- {
- maxx = cnt;
- mod = 0;
- }
- if(cnt == maxx)
- mod++;
- cout<<cnt<<" -- "<<maxx<<" -- "<<mod<<endl<<endl<<endl;
- }
- int main()
- {
- clock_t tStart = clock();
- int n, L;
- Read(n,L);
- int maxx=0, mod=0;
- for(int i=1; i<n; i++)
- DetMax(i,L,maxx,n, mod);
- if(maxx==0 && mod==0)
- cout<<"nu exista"<<endl;
- else
- cout<<maxx<<" "<<mod<<endl;
- cout<<"Timp: "<<(float)(clock()-tStart)/CLOCKS_PER_SEC<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement