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