Submission #233309

# Submission time Handle Problem Language Result Execution time Memory
233309 2020-05-20T08:58:37 Z VEGAnn Segway (COI19_segway) C++14
15 / 100
13 ms 1024 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 loc = i;

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

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

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

            int ps = pos + kol;

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

            loc++;
        }

        i = loc;
    }

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

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 13 ms 1024 KB Output is correct
# 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 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 13 ms 1024 KB Output is correct
6 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -