Pagini recente » Cod sursa (job #2530624) | Cod sursa (job #2411939) | Cod sursa (job #434701) | Cod sursa (job #2494775) | Cod sursa (job #2428382)
#include <bits/stdc++.h>
using namespace std ;
int n , cnt = 1 , ans;
int a[1000024];
ofstream out ("twoton.out") ;
class InputReader {
public:
InputReader() {}
InputReader(const char *file_name) {
input_file = fopen(file_name, "r");
cursor = 0;
fread(buffer, SIZE, 1, input_file);
}
inline InputReader &operator >>(int &n) {
while((buffer[cursor] < '0' || buffer[cursor] > '9')&&buffer[cursor]!='-') {
advance();
}
n =0;
semn= 1;
if(buffer[cursor]=='-') semn=-1,advance();
while('0' <= buffer[cursor] && buffer[cursor] <= '9') {
n = n * 10 + buffer[cursor] - '0';
advance();
}
n*=semn;
return *this;
}
private:
FILE *input_file;
static const int SIZE = 1 << 17;
int cursor,semn;
char buffer[SIZE];
inline void advance() {
++ cursor;
if(cursor == SIZE) {
cursor = 0;
fread(buffer, SIZE, 1, input_file);
}
}
}in("twoton.in");
int main()
{
in >> n ;
for (int i = 0; i < n; ++i)
in >> a [ i ] ;
ans = a [ n - 1 ] ;
for (int i = n-2; i >= 0; -- i ) {
if ( a [ i ]>= ans ) cnt <<= 1 ;
else ans = a [ i ] ;
++ cnt ;
if ( cnt >= 19997 )
cnt -= 19997;
}
out << cnt ;
}