Submission #440009

# Submission time Handle Problem Language Result Execution time Memory
440009 2021-07-01T11:50:47 Z elazarkoren Colouring a rectangle (eJOI19_colouring) C++17
20 / 100
370 ms 14532 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;

const ll infinity = 1e18;

int main() {
    int n, m;
    cin >> n >> m;
    vi dig1(m + n - 1), dig2(n + m - 1);
    ll sum2 = 0, sum1 = 0;
    for (int i = 0; i < m + n - 1; i++) {
        cin >> dig2[i];
        sum2 += dig2[i];
    }
    for (int i = 0; i < n + m - 1; i++) {
        cin >> dig1[i];
        sum1 += dig1[i];
    }
    ll sum = 0;
    for (int i = 0; i < 2 * n - 1; i += 2) sum += dig1[i];
    ll ans1 = sum;
    for (int i = 0; i < n; i += 2) {
        sum -= dig1[i] + dig1[2 * n - i - 2];
        if (i == n - 1) sum += dig1[i];
        sum += dig2[i + n - 1] + dig2[n - i - 1];
        if (!i) {
            sum -= dig2[n - 1];
        }
        chkmin(ans1, sum);
    }
    sum = 0;
    for (int i = 1; i < 2 * n - 1; i += 2) sum += dig1[i];
    ll ans2 = sum;
    for (int i = 1; i < n; i += 2) {
        sum -= dig1[i] + dig1[2 * n - i - 2];
        if (i == n - 1) sum += dig1[i];
        sum += dig2[i + n - 1] + dig2[n - i - 1];
        chkmin(ans2, sum);
    }
    cout << ans1 + ans2;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 174 ms 3404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 370 ms 6476 KB Output is correct
2 Correct 345 ms 14224 KB Output is correct
3 Correct 353 ms 14280 KB Output is correct
4 Correct 356 ms 14480 KB Output is correct
5 Correct 361 ms 14532 KB Output is correct
6 Correct 287 ms 11588 KB Output is correct
7 Correct 352 ms 13964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -