Submission #619904

# Submission time Handle Problem Language Result Execution time Memory
619904 2022-08-02T17:08:52 Z nohaxjustsoflo Semiexpress (JOI17_semiexpress) C++17
100 / 100
7 ms 344 KB
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set;
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//uniform_int_distribution<int> gen; ///(min, max)
//int random() {return gen(mt_rand);}
const int mxN=3e5+5;
const int mod=998244353;
const int mxlogN=20;
const int mxK=26;
const int inf=2e9;
const int K=600;
ll a[mxN], where[mxN];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n,m,k; cin >> n >> m >> k;
    ll A,B,C; cin >> A >> B >> C;
    ll T; cin >> T;
    for(int i=0; i<m; i++) cin >> a[i], a[i]--;
    a[m]=a[m-1]+1;
    for(int i=0; i<m; i++)
    {
        if(T<a[i]*B) where[i]=-1;
        else where[i]=min(a[i+1]-1,a[i]+(T-a[i]*B)/A);
    }
    k=k-m;
    for(int j=0; j<k; j++)
    {
        int mx=0, pos=-1;
        for(int i=0; i<m; i++)
        {
            int x=where[i];
            if(!~x) continue;
            int p=x+1; ///ovde postavljam semiexpress
            if(T<a[i]*B+(p-a[i])*C) continue;
            else
            {
                int x2=min(a[i+1]-1,p+(T-a[i]*B-(p-a[i])*C)/A);
                if(x2-x>mx)
                {
                    mx=x2-x;
                    pos=i;
                }

            }
        }
        if(!mx) break;
        int x=where[pos];
        where[pos]=min(a[pos+1]-1,x+1+(T-a[pos]*B-(x+1-a[pos])*C)/A);
    }
    int ans=-1;
    for(int i=0; i<m; i++) if(~where[i]) ans+=where[i]-a[i]+1;
    cout << ans << "\n";
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 7 ms 340 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 264 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct