here is only basic implementation of problems for beginners. If you have any problem with any solution or any basic concept of programming or you want more efficient solution you can mail me.
my suggestion is not to copy and paste codes from here try to understand the logic and think why you were not able to solve it.

Tuesday, 9 June 2015

Movie Theatre Madness

problem statement is here



#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

struct compare
{
  bool operator()(const long long & l, const long long & r)
  {
      return l > r;
  }
};

int main(){
priority_queue<long long,vector<long long>, compare > pq;
int n,i,a;
long long ar[100005],max=1;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%lld",&ar[i]);
}
for(i=0;i<n;i++){
pq.push(ar[i]);
while(1){
if(pq.top()==ar[i]){
break;
}else{
max=(max*(ar[i]))%1000000007;
pq.pop();
}
}
}
max=max%1000000007;
printf("%lld\n",max);

return 0;
}

No comments:

Post a Comment