Submission #1167792

#TimeUsernameProblemLanguageResultExecution timeMemory
1167792hainam2k9Semiexpress (JOI17_semiexpress)C++20
18 / 100
0 ms328 KiB
#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
#define mp make_pair
using namespace std;
const int MOD = 1e9+7, MAXN = 1e5+5;
const string NAME = "";
int n,m,k,rs=0,a[3005];
ll cost[3],t;
priority_queue<pair<int,pair<ll,int>>> pq;
int main()
{
    tt;
    if(fopen((NAME + ".INP").c_str(), "r")) fo;
    cin >> n >> m >> k;
    for(int i = 0; i<3; ++i)
        cin >> cost[i];
    cin >> t;
    for(int i = 1; i<=m; ++i){
        cin >> a[i];
        rs+=cost[1]*(a[i]-1)<=t;
    }
    k-=m;
    for(int i = 1; i<m; ++i){
        ll used=cost[1]*(a[i]-1);
        if(used>t||a[i+1]-a[i]-1==0) continue;
        int can=min(1ll*a[i+1]-a[i]-1,(t-used)/cost[0]);
        rs+=can, used+=(can+1)*cost[2];
        if(used<=t&&a[i+1]-a[i]-1-can>0){
            int can2=min(1ll*a[i+1]-a[i]-1-can,(t-used)/cost[0]+1);
            pq.ins(can2,mp(used,a[i+1]-a[i]-1-can2));
        }
    }
    while(k>0&&!pq.empty()){
        pair<int,pair<ll,int>> p=pq.top();
        rs+=p.fi, --k, pq.pop();
        ll used=p.se.fi+1ll*p.fi*cost[2];
        if(used<=t&&p.se.se>0){
            int can=min(1ll*p.se.se,(t-used)/cost[0]+1);
            pq.ins(can,mp(used,p.se.se-can));
        }
    }
    cout << rs-1;
}

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:28:45: note: in expansion of macro 'fo'
   28 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
semiexpress.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:28:45: note: in expansion of macro 'fo'
   28 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...