Submission #118106

# Submission time Handle Problem Language Result Execution time Memory
118106 2019-06-18T07:59:07 Z JohnTitor Semiexpress (JOI17_semiexpress) C++11
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
#define __builtin_popcount __builtin_popcountll
using ll=long long; using ld=long double;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi=acos(0)*2;
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
#define taskname "Semiexp"
ll n;
int m, k;
ll t;
ll a, b, c;
ll ans=0;
ll s[3001];
vector <vector <ll>> p;
void prepare(ll x, ll t){
    vector <ll> all;
    ll sum=0;
    while(all.size()<=k){
        all.pb(t/a+1);
        t-=all.back()*c;
        sum+=all.back();
        if(t<0) break;
        if(sum>=x){
            all.back()-=sum-x;
            break;
        }
    }
    reverse(all.begin(), all.end());
    ans+=all.back();
    all.pop_back();
    if(!all.empty()) p.pb(all);
}
class cmp{
public:
    bool operator ()(int a, int b){
        return p[a].back()<p[b].back();
    }
};
priority_queue <int, vector <int>, cmp> q;
int main(){
    #ifdef Aria
        if(fopen(taskname".in", "r"))
            freopen(taskname".in", "r", stdin);
    #endif // Aria
    read(n);
    read(m);
    read(k);
    read(a);
    read(b);
    read(c);
    read(t);
    FOR(i, 1, m) read(s[i]);
    FFOR(i, 1, m){
        ll r=t-(s[i]-1)*b;
        if(r<0) break;
        prepare(s[i+1]-s[i], r);
    }
    k-=m;
    if((n-1)*b>t) ans--;
    int cnt=0;
    FFOR(i, 0, p.size()) q.push(i);
    FOR(i, 1, k){
        if(q.empty()) break;
        int u=q.top();
        q.pop();
        ans+=p[u].back();
        p[u].pop_back();
        if(!p[u].empty()) q.push(u);
    }
    writeln(ans);
}

Compilation message

semiexpress.cpp: In function 'void prepare(ll, ll)':
semiexpress.cpp:30:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(all.size()<=k){
           ~~~~~~~~~~^~~
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:4:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FFOR(i, j, k) for(int i=(j); i<(k); i++)
                                       ^
semiexpress.cpp:73:5: note: in expansion of macro 'FFOR'
     FFOR(i, 0, p.size()) q.push(i);
     ^~~~
semiexpress.cpp:72:9: warning: unused variable 'cnt' [-Wunused-variable]
     int cnt=0;
         ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -