Submission #551748

# Submission time Handle Problem Language Result Execution time Memory
551748 2022-04-21T12:15:51 Z krit3379 Semiexpress (JOI17_semiexpress) C++17
100 / 100
1 ms 340 KB
#include<bits/stdc++.h>
using namespace std;
#define N 3005

long long n,a,b,c,t,x[N],v[N],now,nxt,ans=-1;
priority_queue<pair<long long,long long>> q;

int main(){
    int m,k,i,j;
    scanf("%lld %d %d %lld %lld %lld %lld",&n,&m,&k,&a,&b,&c,&t);
    for(i=1;i<=m;i++)scanf("%lld",&x[i]);
    x[m+1]=n+1;
    k-=m;
    for(i=1;i<=m;i++){
        now=b*(x[i]-1);//time spent
        if(now>t)break;
        nxt=x[i]+(t-now)/a;//move with a->train til we cannot
        nxt=min(nxt,x[i+1]-1);
        ans+=nxt-x[i]+1;
        v[i]=nxt+1;
    }
    for(i=1;i<=m;i++){
        if(v[i]>=x[i+1]||!v[i])continue;
        now=b*(x[i]-1)+c*(v[i]-x[i]);
        if(now>t)continue;
        nxt=v[i]+(t-now)/a;
        nxt=min(nxt,x[i+1]-1);
        q.push({nxt-v[i]+1,i});
        v[i]=nxt+1;
    }
    while(k--&&!q.empty()){
        auto [val,i]=q.top();
        q.pop();
        ans+=val;
        if(v[i]>=x[i+1]||!v[i])continue;
        now=b*(x[i]-1)+c*(v[i]-x[i]);
        if(now>t)continue;
        nxt=v[i]+(t-now)/a;
        nxt=min(nxt,x[i+1]-1);
        q.push({nxt-v[i]+1,i});
        v[i]=nxt+1;
    }
    printf("%lld",ans);
    return 0;
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:9:15: warning: unused variable 'j' [-Wunused-variable]
    9 |     int m,k,i,j;
      |               ^
semiexpress.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%lld %d %d %lld %lld %lld %lld",&n,&m,&k,&a,&b,&c,&t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:11:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(i=1;i<=m;i++)scanf("%lld",&x[i]);
      |                      ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 216 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 216 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
26 Correct 1 ms 316 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 312 KB Output is correct