Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream fin("subsiruri.in");
- ofstream fout("subsiruri.out");
- const int NMAX = 1005;
- const int MOD = 9901;
- int S[NMAX],V[NMAX],D[NMAX];
- int N;
- int main() {
- fin >> N;
- for (int i = 1; i <= N; i++) {
- fin >> V[i];
- }
- V[++N] = 30005;
- D[1] = 1;
- S[1] = 1;
- for (int i = 2; i <= N; i++) {
- int MAX = 0;
- for (int j = 1; j <= N; j++) {
- if (V[i] > V[j]) {
- if (D[j] > MAX) {
- MAX = D[j];
- S[i] = S[j];
- }
- else if (D[j] == MAX)
- {
- S[i] += S[j];
- S[i] %= MOD;
- }
- }
- }
- if (MAX == 0) {
- S[i] = 1;
- }
- D[i] = MAX + 1;
- }
- fout << D[N] - 1 << "\n" << S[N];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment