답안 #919453

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919453 2024-01-31T21:07:49 Z raphaelp Colouring a rectangle (eJOI19_colouring) C++14
30 / 100
248 ms 17772 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long M, N;
    cin >> M >> N;
    vector<long long> GD(N + M - 1), DG(N + M - 1);
    for (long long i = 0; i < N + M - 1; i++)
    {
        cin >> GD[i];
    }
    for (long long i = 0; i < N + M - 1; i++)
    {
        cin >> DG[i];
    }
    if (M == 1)
    {
        long long tot = 0;
        for (long long i = 0; i < N; i++)
        {
            tot += min(DG[i], GD[N - i - 1]);
        }
        cout << tot;
    }
    if (M == N)
    {
        vector<long long> mainDG(N + 1), mainGD(N + 1);
        for (long long i = 0; i < N + M - 1; i++)
        {
            if (i < N)
                mainDG[N - i] += DG[i];
            else
                mainDG[i - N + 2] += DG[i];
            if (i < N)
                mainGD[N - i] += GD[i];
            else
                mainGD[i - N + 2] += GD[i];
        }
        for (long long i = 2; i <= N; i++)
        {
            mainDG[i] += mainDG[i - 2];
            mainGD[i] += mainGD[i - 2];
        }
        long long best = 123456789000000000;
        long long buff = N;
        for (long long i = 0; i <= N; i += 2)
        {
            buff = max(buff, (long long)0);
            best = min(best, mainGD[i] + mainDG[buff]);
            buff -= 2;
            if (i == 0)
                i--;
        }
        long long best2 = 123456789000000000;
        buff = N - 1;
        for (long long i = 0; i <= N; i += 2)
        {
            buff = max(buff, (long long)0);
            best2 = min(best2, mainGD[i] + mainDG[buff]);
            buff -= 2;
        }
        cout << best + best2;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 106 ms 3416 KB Output is correct
2 Correct 107 ms 3552 KB Output is correct
3 Correct 106 ms 3416 KB Output is correct
4 Correct 115 ms 3416 KB Output is correct
5 Correct 114 ms 3416 KB Output is correct
6 Correct 96 ms 3420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 248 ms 9808 KB Output is correct
2 Correct 222 ms 17556 KB Output is correct
3 Correct 227 ms 17432 KB Output is correct
4 Correct 226 ms 17748 KB Output is correct
5 Correct 229 ms 17772 KB Output is correct
6 Correct 167 ms 14676 KB Output is correct
7 Correct 220 ms 17236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -