이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 + 1) % 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[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);
            }
            loc++;
        }
        i = loc;
    }
    for (int i = 0; i < n; i++)
        cout << ans[i] << '\n';
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |