QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#276398 | #7195. Non-descending Sequence | PetroTarnavskyi# | WA | 2ms | 6380kb | C++20 | 1.1kb | 2023-12-05 20:48:04 | 2023-12-05 20:48:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); i--)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int N = 1 << 12;
const int M = 2017;
int dp[N][11 * M];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(15);
int n;
cin >> n;
VI a(n);
FOR(i, 0, n)
cin >> a[i];
RFOR(i, n - 1, 0)
a[i] = min(a[i], a[i + 1]);
int k = a[0] / (11 * M);
FOR(i, 0, n)
a[i] = min(11 * M - 1, a[i] - k * 11 * M);
dp[0][0] = 1;
FOR(i, 0, n)
{
int sum = 0;
FOR(val, 0, a[i] + 1)
{
sum = (sum + dp[i][val]) % M;
dp[i + 1][val] = sum;
}
}
int ans = 0;
FOR(i, 0, a[n - 1] + 1)
ans = (ans + dp[n][i]) % M;
cout << ans << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
2 1 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
3 1 2 4
output:
19
result:
ok 1 number(s): "19"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
1 0
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 1ms
memory: 5664kb
input:
10 2 0 2 0 1 1 1 2 0 1
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 1ms
memory: 5696kb
input:
10 1 9 5 10 9 2 3 0 3 8
output:
30
result:
ok 1 number(s): "30"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
10 5 13 10 9 13 1 20 6 10 5
output:
546
result:
ok 1 number(s): "546"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
10 20 35 10 30 3 34 24 39 12 49
output:
100
result:
ok 1 number(s): "100"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
10 62 65 20 53 87 84 61 68 38 46
output:
376
result:
ok 1 number(s): "376"
Test #9:
score: 0
Accepted
time: 0ms
memory: 5532kb
input:
10 51 223 427 369 264 124 222 241 87 496
output:
1041
result:
ok 1 number(s): "1041"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
10 979 399 460 97 912 441 201 975 168 999
output:
1963
result:
ok 1 number(s): "1963"
Test #11:
score: 0
Accepted
time: 1ms
memory: 5684kb
input:
10 1566 1646 139 307 1044 1630 1804 1297 1570 300
output:
720
result:
ok 1 number(s): "720"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
10 208 4884 3032 3287 328 3351 244 1250 3797 528
output:
1808
result:
ok 1 number(s): "1808"
Test #13:
score: 0
Accepted
time: 2ms
memory: 6380kb
input:
10 39532 139764 61334 65512 103253 123977 122087 108745 39728 21293
output:
1422
result:
ok 1 number(s): "1422"
Test #14:
score: -100
Wrong Answer
time: 1ms
memory: 4512kb
input:
10 973577511 924860842 135145374 333683082 866710766 260390187 469183413 342124177 106180997 379641830
output:
988
result:
wrong answer 1st numbers differ - expected: '966', found: '988'