답안 #1120111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1120111 2024-11-28T03:01:19 Z _callmelucian Sightseeing in Kyoto (JOI22_kyoto) C++14
10 / 100
2000 ms 3580 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tpl;

#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())

const int mn = 1e5 + 5;
ll a[mn], b[mn], ans[mn];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m; cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) cin >> b[i];

    vector<tpl> checkpoints;
    checkpoints.emplace_back(0, 1, 1);

    fill(ans + 1, ans + 1 + n, LLONG_MAX);
    for (int i = 2; i <= n; i++) {
        ll optCol = 0, optVal = LLONG_MAX;
        for (int j = 0; j < checkpoints.size(); j++) {
            ll val, row, curCol; tie(val, row, curCol) = checkpoints[j];
            ll nxtCol = (j + 1 < checkpoints.size() ? get<2>(checkpoints[j + 1]) : m + 1);

            for (int col = curCol; col < nxtCol; col++) {
                ll curVal = val + a[row] * (col - curCol) + b[col] * (i - row);
                if (curVal + a[i] * (m - col) < ans[i])
                    ans[i] = curVal + a[i] * (m - col), optCol = col, optVal = curVal;
            }
        }
        while (checkpoints.size() && get<2>(checkpoints.back()) >= optCol) checkpoints.pop_back();
        checkpoints.emplace_back(optVal, i, optCol);

//        cout << "row " << i << ", check-points: ";
//        for (auto [a, b, c] : checkpoints) cout << "(" << a << " " << b << " " << c << ") ";
//        cout << "\n";
    }
    cout << ans[n];

    return 0;
}

Compilation message

kyoto.cpp: In function 'int main()':
kyoto.cpp:31:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for (int j = 0; j < checkpoints.size(); j++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~
kyoto.cpp:33:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |             ll nxtCol = (j + 1 < checkpoints.size() ? get<2>(checkpoints[j + 1]) : m + 1);
      |                          ~~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 3 ms 2384 KB Output is correct
10 Correct 2 ms 2540 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 3 ms 2384 KB Output is correct
14 Correct 3 ms 2552 KB Output is correct
15 Correct 2 ms 2384 KB Output is correct
16 Correct 2 ms 2384 KB Output is correct
17 Correct 2 ms 2384 KB Output is correct
18 Correct 1 ms 2640 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2516 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2384 KB Output is correct
25 Correct 1 ms 2556 KB Output is correct
26 Correct 1 ms 2552 KB Output is correct
27 Correct 1 ms 2384 KB Output is correct
28 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 2 ms 2384 KB Output is correct
4 Correct 547 ms 2828 KB Output is correct
5 Correct 17 ms 2640 KB Output is correct
6 Correct 3 ms 2788 KB Output is correct
7 Execution timed out 2058 ms 3580 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 3 ms 2384 KB Output is correct
10 Correct 2 ms 2540 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 3 ms 2384 KB Output is correct
14 Correct 3 ms 2552 KB Output is correct
15 Correct 2 ms 2384 KB Output is correct
16 Correct 2 ms 2384 KB Output is correct
17 Correct 2 ms 2384 KB Output is correct
18 Correct 1 ms 2640 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2516 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2384 KB Output is correct
25 Correct 1 ms 2556 KB Output is correct
26 Correct 1 ms 2552 KB Output is correct
27 Correct 1 ms 2384 KB Output is correct
28 Correct 1 ms 2384 KB Output is correct
29 Correct 1 ms 2384 KB Output is correct
30 Correct 1 ms 2384 KB Output is correct
31 Correct 2 ms 2384 KB Output is correct
32 Correct 547 ms 2828 KB Output is correct
33 Correct 17 ms 2640 KB Output is correct
34 Correct 3 ms 2788 KB Output is correct
35 Execution timed out 2058 ms 3580 KB Time limit exceeded
36 Halted 0 ms 0 KB -