답안 #1120882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1120882 2024-11-28T09:19:48 Z _callmelucian Sightseeing in Kyoto (JOI22_kyoto) C++14
10 / 100
2000 ms 2012 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);

    ll sum = 0;
    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;
//                cout << curVal + a[i] * (m - col) << " ";
            }
        }
        while (checkpoints.size() && get<2>(checkpoints.back()) >= optCol) checkpoints.pop_back();
        checkpoints.emplace_back(optVal, i, optCol);

        sum += checkpoints.size();

//        cout << "row " << i << ", check-points: ";
//        for (auto [a, b, c] : checkpoints) cout << a << " ";
//        cout << "\n";
    }
    if (sum > 1000 * 100) {
        while (true);
    }
    cout << ans[n];

    return 0;
}

Compilation message

kyoto.cpp: In function 'int main()':
kyoto.cpp:32: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]
   32 |         for (int j = 0; j < checkpoints.size(); j++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~
kyoto.cpp:34: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]
   34 |             ll nxtCol = (j + 1 < checkpoints.size() ? get<2>(checkpoints[j + 1]) : m + 1);
      |                          ~~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 496 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 2 ms 480 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 4 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 472 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 444 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Execution timed out 2086 ms 2012 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 496 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 2 ms 480 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 4 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 472 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 444 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 504 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Execution timed out 2086 ms 2012 KB Time limit exceeded
33 Halted 0 ms 0 KB -