QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#57981#3894. Generator GridBeevo#WA 46ms4780kbC++231000b2022-10-24 02:32:532022-10-24 02:32:55

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-24 02:32:55]
  • Judged
  • Verdict: WA
  • Time: 46ms
  • Memory: 4780kb
  • [2022-10-24 02:32:53]
  • Submitted

answer

#include <bits/stdc++.h>

#define el '\n'
#define ll long long
#define ld long double

#define Beevo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const ll INF = 1e18;

void testCase() {
    int n, m;
    cin >> n >> m;

    ll c;
    int u;
    vector<ll> cst(n + 1, INF), orgCst(n + 1, INF);
    for (int i = 0; i < m; i++) {
        cin >> u >> c;

        cst[u] = orgCst[u] = c;
    }

    for (int i = 1; i <= n; i++) {
        cin >> c;

        cst[i] = min(cst[i], c);

        if (i + 1 <= n)
            cst[i + 1] = min(cst[i + 1], c);
        else
            cst[1] = min(cst[1], c);
    }

    ll sum = 0;
    for (int i = 1; i <= n; i++)
        sum += cst[i];

    ll sol = INF;
    for (int i = 1; i <= n; i++)
        sol = min(sol, sum - cst[i] + orgCst[i]);

    cout << sol;
}

signed main() {
    Beevo

    int T = 1;
//    cin >> T;

    while (T--)
        testCase();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 2
1 100
2 200
150 300 150

output:

400

result:

ok single line: '400'

Test #2:

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

input:

3 2
1 100
2 200
300 300 150

output:

450

result:

ok single line: '450'

Test #3:

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

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

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

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: 46ms
memory: 4616kb

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: 2ms
memory: 3552kb

input:

3 1
1 1
1 1 1

output:

3

result:

ok single line: '3'

Test #8:

score: -100
Wrong Answer
time: 14ms
memory: 4780kb

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:

27138804055923

result:

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