Submission #167282

# Submission time Handle Problem Language Result Execution time Memory
167282 2019-12-07T07:52:58 Z egekabas Segway (COI19_segway) C++14
100 / 100
477 ms 1780 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pll;
typedef pair<ld, ld>  pld;
ll n;
ll a[20009], b[20009], c[20009];
ll m;
ll ac[20009];
vector<pair<ll, pii>> v;
pair<ll, pii> go(pair<ll, pii> x, ll goal){
    if(x.ss.ff >= goal)
        return x;
    if(x.ss.ff <= 100 && goal >= 100){
        x.ss.ss += (100-x.ss.ff)*a[x.ff];
        x.ss.ff = 100;
    }
    if(x.ss.ff <= 200 && goal >= 200){
        x.ss.ss += (200-x.ss.ff)*b[x.ff];
        x.ss.ff = 200;
    }
    if(goal <= 100){
        x.ss.ss += (goal-x.ss.ff)*a[x.ff];
        x.ss.ff = goal;
    }
    else if(goal <= 200){
        x.ss.ss += (goal-x.ss.ff)*b[x.ff];
        x.ss.ff = goal;
    }
    else{
        x.ss.ss += (goal-x.ss.ff)*c[x.ff];
        x.ss.ff = goal;
    }
    return x;
}
ll stmp;
ll sfunc(pair<ll, pii> a, pair<ll, pii> b){
    return a.ss.ss-max((ll)0, (a.ss.ff-stmp)) > b.ss.ss-max((ll)0, (b.ss.ff-stmp));
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n;
    for(ll i = 0; i < n; ++i){
        cin >> a[i] >> b[i] >> c[i];
        v.pb({i, {0, 0}});
    }
    cin >> m;
    for(ll i = 0; i < m; ++i)
        cin >> ac[i];
    for(ll cur = 0; cur < m; ++cur){
        for(ll j = 0; j < v.size(); ++j)
            v[j] = go(v[j], ac[cur]);
        stmp = ac[cur];
        sort(v.begin(), v.end(), sfunc);
        ll i = 0, j = 0;
        while(i < n){
            for(j = i+1; j < n; ++j)
                if(v[i].ss.ss-max((ll)0, (v[i].ss.ff-stmp)) != v[j].ss.ss-max((ll)0, (v[j].ss.ff-stmp)))
                    break;
            ll add = (n-j)%20;
            for(ll k = i; k < j; ++k){
                if(v[k].ss.ff == ac[cur]){
                    v[k].ss.ff += add;
                    v[k].ss.ss += add;
                }
            }
            i = j;
        }
    }
    for(ll j = 0; j < v.size(); ++j){
        v[j] = go(v[j], 300);
        if(v[j].ss.ff > 300){
            v[j].ss.ss -= v[j].ss.ff - 300;
            v[j].ss.ff = 300; 
        }
    }
    sort(v.begin(), v.end());
    for(auto u : v)
        cout << u.ss.ss << "\n";
}

Compilation message

segway.cpp: In function 'int main()':
segway.cpp:64:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(ll j = 0; j < v.size(); ++j)
                       ~~^~~~~~~~~~
segway.cpp:83:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll j = 0; j < v.size(); ++j){
                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 656 KB Output is correct
5 Correct 15 ms 1776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 656 KB Output is correct
5 Correct 15 ms 1776 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 40 ms 588 KB Output is correct
19 Correct 75 ms 1080 KB Output is correct
20 Correct 21 ms 1140 KB Output is correct
21 Correct 142 ms 1376 KB Output is correct
22 Correct 333 ms 1780 KB Output is correct
23 Correct 477 ms 1780 KB Output is correct