Pagini recente » Cod sursa (job #1654495) | Cod sursa (job #341363) | Cod sursa (job #2581906) | Cod sursa (job #431708) | Cod sursa (job #1710580)
#include <iostream>
using namespace std;
int DP[100005];
int a[100005];
int wtf[100005];
int main(){
ifstream in("twoton.in");
ofstream out("twoton.out");
int n;
in>>n;
for(int i=0; i<n;i++){
in>>a[i];
}
wtf[n-1] = a[n-1];
for(int i = n-2; i >= 0; i--){
wtf[i] = a[i] < wtf[i+1] ? a[i] : wtf[i+1];
}
DP[n-1] = 1;
for(int i = n-2; i>=0; i--){
DP[i] = (1 + (a[i] < wtf[i+1] ? DP[i+1] : 2 * DP[i+1]))%19997;
}
out << DP[0];
return 0;
}