Submission #233306

# Submission time Handle Problem Language Result Execution time Memory
233306 2020-05-20T08:56:51 Z VEGAnn Segway (COI19_segway) C++14
0 / 100
1000 ms 512 KB
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define PB push_back
using namespace std;
const int N = 20100;
const int md = int(1e9) + 7;
int a[N][3], n, nm[N], tim[N], m, pos, ans[N];

bool cmp(int _x, int _y){
    return tim[_x] < tim[_y];
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> a[i][0] >> a[i][1] >> a[i][2];

    cin >> m;

    assert(m == 1);

    cin >> pos;

    for (int i = 0; i < n; i++){
        tim[i] = 0;

        if (pos < 100){
            tim[i] = a[i][0] * pos;
        } else if (pos < 200){
            tim[i] = a[i][1] * (pos - 100) + a[i][0] * 100;
        } else {
            tim[i] = a[i][2] * (pos - 200) + a[i][1] * 100 + a[i][0] * 100;
        }

        nm[i] = i;
    }

    sort(nm, nm + n, cmp);

    for (int i = 0; i < n; ){
        int j = i;

        int kol = min(300 - pos, (i + 1) % 20);

        while (j < n && tim[nm[i]] == tim[nm[j]]){
            int loc = nm[j];

            ans[j] = tim[j] + kol;

            int ps = pos + kol;

            if (ps < 100){
                ans[j] += a[i][0] * (100 - ps) + a[i][1] * 100 + a[i][2] * 100;
            } else if (ps < 200){
                ans[j] += a[i][1] * (200 - ps) + a[i][2] * 100;
            } else {
                ans[j] += a[i][2] * (300 - ps);
            }

            j++;
        }
    }

    for (int i = 0; i < n; i++)
        cout << ans[i] << '\n';

    return 0;
}

Compilation message

segway.cpp: In function 'int main()':
segway.cpp:53:17: warning: unused variable 'loc' [-Wunused-variable]
             int loc = nm[j];
                 ^~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -