답안 #225346

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
225346 2020-04-20T09:57:17 Z MKopchev Semiexpress (JOI17_semiexpress) C++14
100 / 100
27 ms 2548 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=3e3+42;

int n,m,k;

int slow,fast,average;

long long t;

int stop[nmax];

vector<int> gains;

bool cmp(int u,int v)
{
    return u>v;
}
int main()
{
    scanf("%i%i%i",&n,&m,&k);

    k=k-m;

    scanf("%i%i%i",&slow,&fast,&average);

    scanf("%lld",&t);

    for(int i=1;i<=m;i++)scanf("%i",&stop[i]);

    long long output=-1;//remove 1

    if(1LL*(n-1)*fast<=t)output++;//add n

    for(int i=1;i<m;i++)
    {
        long long t_now=1LL*(stop[i]-1)*fast;

        if(t_now>t)break;

        long long gain=min((t-t_now)/slow+1,1LL*stop[i+1]-stop[i]);

        output+=gain;

        //cout<<i<<" -> "<<gain<<endl;

        int pos=stop[i];

        for(int j=1;j<=k;j++)
        {
            pos+=gain;
            if(pos==stop[i+1])break;

            t_now+=average*gain;

            if(t_now>t)break;

            gain=min((t-t_now)/slow+1,1LL*stop[i+1]-pos);

            gains.push_back(gain);
        }
    }
    /*
    cout<<output<<endl;
    cout<<"gains: ";for(auto w:gains)cout<<w<<" ";cout<<endl;
    */
    sort(gains.begin(),gains.end(),cmp);

    for(int i=0;i<k&&i<gains.size();i++)
        output+=gains[i];

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

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:69:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<k&&i<gains.size();i++)
                      ~^~~~~~~~~~~~~
semiexpress.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i%i",&n,&m,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~
semiexpress.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i%i",&slow,&fast,&average);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&t);
     ~~~~~^~~~~~~~~~~
semiexpress.cpp:29:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=m;i++)scanf("%i",&stop[i]);
                          ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 6 ms 512 KB Output is correct
23 Correct 27 ms 2548 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 20 ms 2548 KB Output is correct
30 Correct 14 ms 1528 KB Output is correct