QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#100270#5681. Caravan Trip PlansNicolas125841WA 2ms3500kbC++14889b2023-04-25 14:04:092023-04-25 14:04:12

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-25 14:04:12]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3500kb
  • [2023-04-25 14:04:09]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

int main(){
    cin.tie(NULL)->sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    vector<int> oas(n);
    for(int i = 0; i < n; i++)
        cin >> oas[i];

    for(int i = 0; i < m; i++){
        int t, d;
        cin >> t >> d;

        t--;

        vector<vector<int>> dp(oas[t]+1, vector<int>(d+1, 0));

        for(int j = 0; j <= d; j++)
            dp[0][j] = 1;

        int ind = 0; 
        for(int j = 1; j <= oas[t]; j++){
            if(j == oas[ind]){
                for(int k = 1; k <= d; k++)
                    dp[j][k] += dp[j-1][k-1] + dp[j][k-1];                

                ++ind;
            }else{
                for(int k = 1; k <= d; k++)
                    dp[j][k] = dp[j-1][k-1];
            }
        }

        cout << dp[oas[t]][d] << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3380kb

input:

5 1
2 3 5 7 11
3 7

output:

10

result:

ok single line: '10'

Test #2:

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

input:

8 3
2 3 5 7 11 13 17 19
3 7
5 15
8 24

output:

10
126
1287

result:

ok 3 lines

Test #3:

score: 0
Accepted
time: 2ms
memory: 3352kb

input:

15 5
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47
7 23
10 35
4 14
5 23
15 56

output:

1716
8008
330
6188
1307504

result:

ok 5 lines

Test #4:

score: 0
Accepted
time: 2ms
memory: 3400kb

input:

20 5
3 5 8 10 13 15 18 20 23 25 28 30 33 35 38 40 43 45 48 50
5 23
7 25
13 39
16 50
20 59

output:

3003
3432
27132
5311735
10015005

result:

ok 5 lines

Test #5:

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

input:

20 5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
7 10
3 7
15 20
20 25
11 18

output:

120
35
15504
53130
31824

result:

ok 5 lines

Test #6:

score: 0
Accepted
time: 2ms
memory: 3452kb

input:

20 5
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
5 15
12 29
8 19
15 40
20 50

output:

252
6188
165
3268760
30045015

result:

ok 5 lines

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3452kb

input:

20 5
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
20 60
19 60
18 60
17 60
16 60

output:

407575348
-150465672
1509802778
264853750
102978202

result:

wrong answer 1st lines differ - expected: '137846528820', found: '407575348'