Submission #1041456

#TimeUsernameProblemLanguageResultExecution timeMemory
1041456vjudge1Segway (COI19_segway)C++17
100 / 100
24 ms1376 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

void solve(){
    ll n , m , k , a , mx = 0;
    cin >> n;
    int ls[n + 1][4];
    for(int i =1 ;i <= n ;i ++){
        for(int j = 0; j< 3; j++){
            cin >> ls[i][j];
        }
    }
    vector<ll> pre(15050) , acc(310) , ans(n + 1) , pos(n + 1) , sped(n + 1);
    cin >> m;
    for(int i =0 ;i < m ;i ++){
        cin >> a;
        acc[a] = 1;
    }
    for(int i = 0 ;i< 300; i ++){
        for(int  j =0 ; j< 15050; j ++){
            pre[j] = 0;
        }
        ll mx = 0;
        for(int j = 1; j <=n ; j++){
            pre[ans[j]] += 1;
            mx = max(mx , ans[j]);
        }
        for(int  j =1 ; j <= mx; j ++){
            pre[j] += pre[j - 1];
        }
        for (int j = 1; j <= n; j++){
            if (sped[j] and pos[j] < 300){
                pos[j] += 1;
                ans[j] += 1;
                sped[j] -= 1;
            }
            else if (pos[j] < 300){
                ll val = 0;
                if(ans[j] - 1 >= 0){
                    val = pre[ans[j] - 1] % 20;
                }
                if (acc[i]){
                    sped[j] = val;
                }
                if (sped[j]){
                    sped[j] -= 1;
                    pos[j] += 1;
                    ans[j] += 1;
                }
                else{
                    ans[j] += ls[j][i / 100];
                }
            }
        }
    }
    for(int i = 1; i<= n ;i ++){
        cout << ans[i] << '\n';
    }

}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int tests = 1;
    // cin >> tests;
    for (int i = 1; i <= tests; i++){
        solve();
    }
    return 0;
}

Compilation message (stderr)

segway.cpp: In function 'void solve()':
segway.cpp:7:16: warning: unused variable 'k' [-Wunused-variable]
    7 |     ll n , m , k , a , mx = 0;
      |                ^
segway.cpp:7:24: warning: unused variable 'mx' [-Wunused-variable]
    7 |     ll n , m , k , a , mx = 0;
      |                        ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...