# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
486367 | rainboy | Žarulje (COI15_zarulje) | C11 | 793 ms | 34028 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#define N 200000
#define SMALL 2000
#define MD 1000000007
int main() {
static int aa[N], dp[SMALL][SMALL];
int n, k, i, j;
scanf("%d%d", &n, &k);
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
for (i = 0; i < n; i++)
for (j = n - 1; j >= 0; j--)
if (i == 0 && j == n - 1)
dp[i][j] = 1;
else if (i == 0)
dp[i][j] = dp[i][j + 1];
else if (j == n - 1)
dp[i][j] = dp[i - 1][j];
else if (aa[i] > aa[j])
dp[i][j] = dp[i - 1][j];
else if (aa[i] < aa[j])
dp[i][j] = dp[i][j + 1];
else
dp[i][j] = (dp[i - 1][j] + dp[i][j + 1]) % MD;
while (k--) {
scanf("%d", &i), i--;
printf("%d\n", dp[i][i]);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |