QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#276395#7195. Non-descending SequencePetroTarnavskyi#WA 1ms5584kbC++201.0kb2023-12-05 20:47:162023-12-05 20:47:17

Judging History

This is the latest submission verdict.

  • [2023-12-05 20:47:17]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5584kb
  • [2023-12-05 20:47:16]
  • Submitted

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][4 * 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] / M;
	FOR(i, 0, n)
		a[i] = min(4 * M - 1, a[i] - k * 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: 1ms
memory: 3436kb

input:

2
1 1

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

3
1 2 4

output:

19

result:

ok 1 number(s): "19"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3468kb

input:

1
0

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 1ms
memory: 5584kb

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: 0ms
memory: 3548kb

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: 3468kb

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: 1ms
memory: 3480kb

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: 3476kb

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: 1ms
memory: 3512kb

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: 1ms
memory: 3532kb

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: 0ms
memory: 3524kb

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: 3544kb

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: 1ms
memory: 3524kb

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: 3504kb

input:

10
973577511 924860842 135145374 333683082 866710766 260390187 469183413 342124177 106180997 379641830

output:

988

result:

wrong answer 1st numbers differ - expected: '966', found: '988'