답안 #322622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
322622 2020-11-15T03:14:29 Z daniel920712 Semiexpress (JOI17_semiexpress) C++14
100 / 100
3 ms 748 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>

using namespace std;

long long all[3005];
map < long long , long long > Con;
set < long long > have,have2;
vector < long long > how;
priority_queue < pair < long long , pair < long long , long long > > , vector < pair < long long , pair < long long , long long > > > , less < pair < long long , pair < long long , long long > > > > ttt;
bool F(long long a,long long b)
{
    return a>b;
}
int main()
{
    //freopen("01-01.txt","rt",stdin);
    long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,l,r,xx;
    scanf("%lld %lld %lld",&N,&M,&K);
    scanf("%lld %lld %lld",&a,&b,&c);
    scanf("%lld",&t);
    for(i=0;i<M;i++)
    {
        scanf("%lld",&all[i]);
        have.insert(all[i]);
        have2.insert(all[i]);
    }

    con=M;
    ans+=min(t/a,N-1);
    xx=t/a+1;
    //printf("%lld\n",ans);
    for(i=0;i<M-1;i++)
    {

        if((all[i]-1)*b<=t)
        {
            l=all[i];
            r=(t-(all[i]-1)*b)/a+all[i];
            r=min(r,all[i+1]-1);

            if(r>xx)
            {
                if(l<=xx) ans+=max((long long) 0,(r-xx));
                else ans+=r-l+1;
            }

            l=max(r+1,xx+1);

            Con[l]=(*prev(have.lower_bound(l))-1)*b+c*(l-*prev(have.lower_bound(l)));
            if(Con[l]<=t&&l>=all[i]&&l<all[i+1])
            {

                r=min(*have.lower_bound(l)-1,l+(t-Con[l])/a);
                ttt.push(make_pair(r-l+1,make_pair(i,r)));

            }




        }
    }

    if((all[M-1]-1)*b<=t&&(all[M-1]-1)*a>t) ans++;

    while(!ttt.empty()&&con<K)
    {
        con++;

        ans+=max((long long) 0,ttt.top().first);

        x=ttt.top().second.first;
        r=ttt.top().second.second;

        ttt.pop();
        l=max(r+1,xx+1);
        Con[l]=(all[x]-1)*b+c*(l-all[x]);
        if(Con[l]<=t&&l>=all[x]&&l<all[x+1])
        {
            r=min(all[x+1]-1,l+(t-Con[l])/a);
            ttt.push(make_pair(r-l+1,make_pair(x,r)));
        }
    }


    printf("%lld\n",ans);
    return 0;
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:24:29: warning: unused variable 'y' [-Wunused-variable]
   24 |     long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,l,r,xx;
      |                             ^
semiexpress.cpp:24:31: warning: unused variable 'z' [-Wunused-variable]
   24 |     long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,l,r,xx;
      |                               ^
semiexpress.cpp:24:47: warning: unused variable 'now' [-Wunused-variable]
   24 |     long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,l,r,xx;
      |                                               ^~~
semiexpress.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |     scanf("%lld %lld %lld",&N,&M,&K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |     scanf("%lld %lld %lld",&a,&b,&c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |     scanf("%lld",&t);
      |     ~~~~~^~~~~~~~~~~
semiexpress.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |         scanf("%lld",&all[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 640 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 2 ms 492 KB Output is correct
23 Correct 3 ms 748 KB Output is correct
24 Correct 2 ms 620 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 2 ms 620 KB Output is correct
28 Correct 2 ms 620 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 492 KB Output is correct