Submission #222576

#TimeUsernameProblemLanguageResultExecution timeMemory
222576kingfran1907Segway (COI19_segway)C++14
100 / 100
293 ms1404 KiB
#include <bits/stdc++.h>

using namespace std;
const int maxn = 2e4+10;

int n, m;
int v[maxn][3];
int dis[maxn];
int ac[maxn];
bool flag[maxn];

vector< pair<int, int> > tren, cp;

int main() {
    memset(flag, false, sizeof flag);
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
            scanf("%d", &v[i][j]);

    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
        int x;
        scanf("%d", &x);
        flag[x] = true;
    }

    for (int i = 0; i < n; i++)
        tren.push_back(make_pair(0, i));

    for (int t = 0; t < 300; t++) {
        cp.clear();

        int cnt = 0;
        int preftim = -1;
        for (int i = 0; i < n; i++) {
            int tim = tren[i].first;
            int ind = tren[i].second;

            if (tim != preftim) cnt = i;
            preftim = tim;

            if (flag[t] && ac[ind] == 0) ac[ind] = cnt % 20;
            if (ac[ind] > 0) {
                ac[ind]--;
                dis[ind]++;
            } else
                dis[ind] += v[ind][t / 100];

            cp.push_back(make_pair(dis[ind], ind));
        }

        tren = cp;
        sort(tren.begin(), tren.end());
    }
    for (int i = 0; i < n; i++)
        printf("%d\n", dis[i]);
    return 0;
}

Compilation message (stderr)

segway.cpp: In function 'int main()':
segway.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
segway.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &v[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~
segway.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &m);
     ~~~~~^~~~~~~~~~
segway.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...