Submission #847882

#TimeUsernameProblemLanguageResultExecution timeMemory
847882MuntherCarrotOvertaking (IOI23_overtaking)C++17
10 / 100
3 ms348 KiB
// by me
#include "overtaking.h"

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define all(x) x.begin(), x.end()
const int MOD = 1e9 + 7, SZ = 1e5 + 10, INF = 1e9;

vector<vector<ll>> vec;
int n, m;

void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S)
{
    vec.assign(N + 1, vector<ll>(M));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            vec[i][j] = 1ll * W[i] * S[j] + T[i];
        }
    }
    for(int j = 0; j < M; j++){
        vec[N][j] = 1ll * X * S[j];
    }
    n = N, m = M;
    // for(int i : vec[N]) cout << i << ' ';
    // cout << endl;
    return;
}

long long arrival_time(long long Y)
{
    vector<ll> ot(n);
    for(int i = 0; i < n; i++){
        ot[i] = Y > vec[i][0];
    }

    ll ans = 0;
    for(int j = 1; j < m; j++){
        ll en = vec[n][j] + Y;
        ll mx = en;
        for(int i = 0; i < n; i++){
            ll ei = vec[i][j] * ot[i];
            mx = max(ei, mx);
            if(ei >= en) ot[i] = 0;
        }
        // cout << mx << ' ';
        ans += mx - ans;
    }

    return ans;
}
// int32_t main(){
//     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//     int L, N, X, M, Q;
//     assert(5 == scanf("%d %d %d %d %d", &L, &N, &X, &M, &Q));
//     std::vector<long long> T(N);
//     for (int i = 0; i < N; i++)
//         assert(1 == scanf("%lld", &T[i]));
//     std::vector<int> W(N);
//     for (int i = 0; i < N; i++)
//         assert(1 == scanf("%d", &W[i]));
//     std::vector<int> S(M);
//     for (int i = 0; i < M; i++)
//         assert(1 == scanf("%d", &S[i]));
//     std::vector<long long> Y(Q);
//     for (int i = 0; i < Q; i++)
//         assert(1 == scanf("%lld", &Y[i]));
// 
//     fclose(stdin);
// 
//     init(L, N, T, W, X, M, S);
//     std::vector<long long> res(Q);
//     for (int i = 0; i < Q; i++)
//         res[i] = arrival_time(Y[i]);
// 
//     for (int i = 0; i < Q; i++)
//         printf("%lld\n", res[i]);
//     fclose(stdout);
//     return 0;
// }
// by me
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...