Submission #155538

# Submission time Handle Problem Language Result Execution time Memory
155538 2019-09-29T03:40:03 Z Learner99 Segway (COI19_segway) C++14
40 / 100
1000 ms 84932 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;  

#define int long long
#define N 100006

int a[N][3];


  
#define ordered_set tree< pair < int , int > , null_type,less< pair < int , int > >, rb_tree_tag,tree_order_statistics_node_update> 
 
ordered_set s[405];
int acc[405] = {0};
int cur[N];
int ans[N];

int32_t main()
{
    int n;
    cin>>n;

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

    int m;
    cin>>m;
    
    for(int i=0;i<m;i++)
    {
        int temp;
        cin>>temp;
        acc[temp] = 1;
    }

    set < pair < int , int > > rid; 
    
    for(int i=1;i<=n;i++)
    {
        rid.insert({0, i});
    }
    while(rid.size()!=0)
    {
        pair < int , int > t = *rid.begin();
        rid.erase(t);
        int tme = t.first;
        int rider = t.second;

        if( acc[cur[rider]] == 0)
        {
            cur[rider]++;
            int x = 0;
            if(cur[rider]<= 100)
            {
                ans[rider]+=a[rider][0];
                x = a[rider][0];
            }
            else if(cur[rider]<=200)
            {
                ans[rider]+=a[rider][1];
                x = a[rider][1];
            }
            else
            {
                ans[rider]+=a[rider][2];
                x = a[rider][2];
            }

            if(cur[rider]<300)
            {
                rid.insert({tme+x, rider});
            }
            s[cur[rider]].insert({tme+x, rider});
        }
        else
        {
            int aage = s[cur[rider]].order_of_key({tme, 0});
            aage%=20;

            if(aage==0)
            {
                cur[rider]++;
                int x = 0;
                if(cur[rider]<= 100)
                {
                    ans[rider]+=a[rider][0];
                    x = a[rider][0];
                }
                else if(cur[rider]<=200)
                {
                    ans[rider]+=a[rider][1];
                    x = a[rider][1];
                }
                else
                {
                    ans[rider]+=a[rider][2];
                    x = a[rider][2];
                }

                if(cur[rider]<300)
                {
                    rid.insert({tme+x, rider});
                }
                s[cur[rider]].insert({tme+x, rider});
            }
            else
            {
                int y = 1;
                int p = cur[rider];
                for(int i=p+1;i<=min(300ll, p+aage);i++)
                {
                    ans[rider]++;
                    cur[rider]++;
                    s[i].insert({tme+y, rider});
                    y++;
                }

                if(cur[rider] < 300)
                    rid.insert({tme+aage, rider});
            }
        }
    }

    for(int i=1;i<=n;i++)
    {
        cout<<ans[i]<<"\n";
    }
    cout<<endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 38 ms 4216 KB Output is correct
3 Correct 191 ms 15480 KB Output is correct
4 Correct 944 ms 56972 KB Output is correct
5 Execution timed out 1056 ms 84932 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 7 ms 1144 KB Output is correct
6 Correct 7 ms 1400 KB Output is correct
7 Correct 14 ms 2040 KB Output is correct
8 Correct 29 ms 3704 KB Output is correct
9 Correct 35 ms 4600 KB Output is correct
10 Correct 55 ms 6008 KB Output is correct
11 Correct 35 ms 4984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 38 ms 4216 KB Output is correct
3 Correct 191 ms 15480 KB Output is correct
4 Correct 944 ms 56972 KB Output is correct
5 Execution timed out 1056 ms 84932 KB Time limit exceeded