QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#56908#3894. Generator GridMahmoudAtia#WA 31ms21664kbC++1.3kb2022-10-21 21:04:032022-10-21 21:04:05

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.
  • [2022-10-21 21:04:05]
  • Judged
  • Verdict: WA
  • Time: 31ms
  • Memory: 21664kb
  • [2022-10-21 21:04:03]
  • Submitted

answer

#include <bits/stdc++.h>

typedef long double ld;
typedef long long ll;
using namespace std;
int di[] = {1, 0, -1, -1, 0, 1, -1, 1};
int dj[] = {1, 1, 0, -1, -1, 0, 1, -1};
const ll oo = 1e18, MOD = 998244353;
const int N = 2e5 + 5, M = 1e6 + 5;
const ld PI = acos(-1.0), EPS = 1e-9;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll n, m, a[N], b[N], dp[N][2][2];

ll solve(int idx, int pre, int done) {
    if (idx > n) return 0;
    ll &ret = dp[idx][pre][done];
    if (~ret) return ret;
    ret = oo;
    if (a[idx] != oo) ret = min(ret, a[idx] + solve(idx + 1, 1, 1));
    if (pre) ret = min(ret, b[idx - 1] + solve(idx + 1, 1, 1));
    if (idx < n || done) ret = min(ret, b[idx] + solve(idx + 1, pre, done));
    return ret;
}

//#define endl '\n'
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen("farm.in", "r", stdin);
    memset(dp, -1, sizeof dp);
    cin >> n >> m;
    fill(a, a + N, oo);
    while (m--) {
        ll x, val;
        cin >> x >> val;
        a[x] = min(a[x], val);
    }
    for (int i = 1; i <= n; i++) cin >> b[i];
    cout << solve(1, 0, 0);
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 7ms
memory: 11480kb

input:

3 2
1 100
2 200
150 300 150

output:

400

result:

ok single line: '400'

Test #2:

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

input:

3 2
1 100
2 200
300 300 150

output:

450

result:

ok single line: '450'

Test #3:

score: 0
Accepted
time: 5ms
memory: 11456kb

input:

100 1
1 100
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ...

output:

1090

result:

ok single line: '1090'

Test #4:

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

input:

100 100
1 100
2 100
3 100
4 100
5 100
6 100
7 100
8 100
9 100
10 100
11 100
12 100
13 100
14 100
15 100
16 100
17 100
18 100
19 100
20 100
21 100
22 100
23 100
24 100
25 100
26 100
27 100
28 100
29 100
30 100
31 100
32 100
33 100
34 100
35 100
36 100
37 100
38 100
39 100
40 100
41 100
42 100
43 100
...

output:

1090

result:

ok single line: '1090'

Test #5:

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

input:

100 100
1 10
2 10
3 10
4 10
5 10
6 10
7 10
8 10
9 10
10 10
11 10
12 10
13 10
14 10
15 10
16 10
17 10
18 10
19 10
20 10
21 10
22 10
23 10
24 10
25 10
26 10
27 10
28 10
29 10
30 10
31 10
32 10
33 10
34 10
35 10
36 10
37 10
38 10
39 10
40 10
41 10
42 10
43 10
44 10
45 10
46 10
47 10
48 10
49 10
50 10
5...

output:

1000

result:

ok single line: '1000'

Test #6:

score: 0
Accepted
time: 29ms
memory: 21664kb

input:

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

output:

100000000000000

result:

ok single line: '100000000000000'

Test #7:

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

input:

3 1
1 1
1 1 1

output:

3

result:

ok single line: '3'

Test #8:

score: -100
Wrong Answer
time: 31ms
memory: 21644kb

input:

100000 74767
1 138940954
3 19986181
5 695152941
10 25582537
11 140007031
12 569374311
13 525539419
14 469038348
15 801427429
17 726991668
18 93743389
19 428218490
20 814325266
21 828939972
22 199634162
24 681381870
25 764678772
26 999070500
27 348411791
28 17375761
29 102004979
30 671397756
32 29838...

output:

27138820410741

result:

wrong answer 1st lines differ - expected: '32622097081612', found: '27138820410741'