Submission #321802

# Submission time Handle Problem Language Result Execution time Memory
321802 2020-11-13T11:49:39 Z daniel920712 Semiexpress (JOI17_semiexpress) C++14
48 / 100
1000 ms 620 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

long long all[3005];
map < long long , long long > Con;
set < long long > have,have2;
vector < long long > how;
bool F(long long a,long long b)
{
    return a>b;
}
int main()
{
    //freopen("02-08.txt","rt",stdin);
    long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,ttt=0;
    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[all[i]]=(all[i]-1)*b;
    }
    //printf("%d\n",how.size());
    con=M;
    for(i=1;i<=N;i++)
    {
        //if(!how.empty()) printf("%d %d\n",how.size(),how[0]);
        if((i-1)*a<=t)
        {
            //printf("aa %lld\n",i);
            ans++;
        }
        else
        {
            if(have.find(i)!=have.end())
            {
                if((i-1)*b<=t)
                {
                    //printf("bb %lld\n",i);
                    //printf("tttt %lld\n",ttt);
                    how.push_back(ttt);
                    ttt=0;
                    ans++;
                }
            }
            else
            {
                if((*prev(have.lower_bound(i))-1)*b+(i-*prev(have.lower_bound(i)))*a<=t)
                {
                    //printf("cc %lld\n",i);
                    ans++;
                    continue;
                }
                if(Con[*prev(have2.lower_bound(i))]+(i-*prev(have2.lower_bound(i)))*a<=t)
                {
                    //printf("ee %lld\n",i);
                    ttt++;
                    continue;
                }
                else
                {
                    //printf("tttt %lld\n",ttt);
                    how.push_back(ttt);
                    ttt=0;
                }

                if((i-*prev(have.lower_bound(i)))*c+(*prev(have.lower_bound(i))-1)*b<=t)
                {
                    //printf("dd %lld\n",i);
                    Con[i]=(i-*prev(have.lower_bound(i)))*c+(*prev(have.lower_bound(i))-1)*b;

                    ttt=1;
                    have2.insert(i);
                }


            }
        }
    }
    //printf("%lld\n",ans);
    //printf("tttt %lld\n",ttt);
    how.push_back(ttt);
    sort(how.begin(),how.end(),F);
    //for(auto i:how) printf("%lld ",i);
    for(i=M;i<K&&i-M<how.size();i++) ans+=how[i-M];
    printf("%lld\n",ans-1);
    return 0;
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:96:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |     for(i=M;i<K&&i-M<how.size();i++) ans+=how[i-M];
      |                  ~~~^~~~~~~~~~~
semiexpress.cpp:22:27: warning: unused variable 'x' [-Wunused-variable]
   22 |     long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,ttt=0;
      |                           ^
semiexpress.cpp:22:29: warning: unused variable 'y' [-Wunused-variable]
   22 |     long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,ttt=0;
      |                             ^
semiexpress.cpp:22:31: warning: unused variable 'z' [-Wunused-variable]
   22 |     long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,ttt=0;
      |                               ^
semiexpress.cpp:22:41: warning: variable 'con' set but not used [-Wunused-but-set-variable]
   22 |     long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,ttt=0;
      |                                         ^~~
semiexpress.cpp:22:47: warning: unused variable 'now' [-Wunused-variable]
   22 |     long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,ttt=0;
      |                                               ^~~
semiexpress.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |     scanf("%lld %lld %lld",&N,&M,&K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |     scanf("%lld %lld %lld",&a,&b,&c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |     scanf("%lld",&t);
      |     ~~~~~^~~~~~~~~~~
semiexpress.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |         scanf("%lld",&all[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 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 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 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 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 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 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 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 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 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 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Execution timed out 1088 ms 620 KB Time limit exceeded
20 Halted 0 ms 0 KB -