Submission #1093017

# Submission time Handle Problem Language Result Execution time Memory
1093017 2024-09-25T17:42:47 Z ortsac Olympic Bus (JOI20_ho_t4) C++17
0 / 100
1000 ms 169944 KB
#include <bits/stdc++.h>

using namespace std;

int brute(int n, int l, vector<int> x1, vector<int> t1) {
    vector<int> v, ti;
    for (int i = 0; i < n; i++) {
        v.push_back(x1[i] - l);
        ti.push_back(t1[i]);
    }
    v.push_back(0);
    ti.push_back(-1);
    for (int i = 0; i < n; i++) {
        v.push_back(x1[i]);
        ti.push_back(t1[i]);
    }
    int ans = 0;
    for (int mask = 0; mask < (1 << n); mask++) {
        int l = n, r = n, are = n, curr = 0, qtd = 0;
        for (int i = 0; i < n; i++) {
            bool k = (mask & (1LL << i));
            if (k) {
                // go to r + 1
                curr += (v[r + 1] - v[are]);
                if (ti[r + 1] >= curr) qtd++;
                are = r + 1;
                r++;
            } else {
                curr += (v[are] - v[l - 1]);
                if (ti[l - 1] >= curr) qtd++;
                are = l - 1;
                l--;
            }
        }
        ans = max(ans, qtd);
    }
    return ans;
}

int32_t main() {
    freopen("in", "r", stdin);
    int n, l;
    cin >> n >> l;
    vector<int> x1(n), t1(n);
    for (int i = 0; i < n; i++) {
        cin >> x1[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> t1[i];
    }
    cout << brute(n, l, x1, t1) << "\n";
}

Compilation message

ho_t4.cpp: In function 'int32_t main()':
ho_t4.cpp:41:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     freopen("in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 169944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1056 ms 169756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 169900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 169944 KB Time limit exceeded
2 Halted 0 ms 0 KB -