Submission #172471

# Submission time Handle Problem Language Result Execution time Memory
172471 2020-01-01T15:48:21 Z mhy908 Semiexpress (JOI17_semiexpress) C++14
0 / 100
2 ms 256 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL llinf=9000000000000000000;
const int inf=2000000000;
int m, k;
LL n, a, b, c, t;
LL arr[3010], ans;
vector<LL> vc;
int main()
{
    scanf("%lld %d %d", &n, &m, &k);
    scanf("%lld %lld %lld %lld", &a, &b, &c, &t);
    k-=m;
    for(int i=1; i<=m; i++){
        scanf("%lld", &arr[i]);
    }
    arr[m+1]=n;
    for(int i=1; i<=m; i++){
        LL now=arr[i];
        for(int j=0; j<=k&&now<arr[i+1]; j++){
            if(t<b*(arr[i]-1)+c*(now-arr[i]))break;
            LL nex=(t-b*(arr[i]-1)-c*(now-arr[i]))/a+now;
            if(j==1){
                if(nex<arr[i+1])ans+=nex-now+1, now=nex+1;
                else{
                    ans+=arr[i+1]-now;
                    break;
                }
            }
            else{
                if(nex<arr[i+1])vc.pb(nex-now+1), now=nex+1;
                else{
                    vc.pb(arr[i+1]-now);
                    break;
                }
            }
        }
    }
    sort(all(vc), greater<LL>());
    for(int i=0; i<vc.size()&&i<k; i++)ans+=vc[i];
    printf("%lld", ans);
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:48:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<vc.size()&&i<k; i++)ans+=vc[i];
                  ~^~~~~~~~~~
semiexpress.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %d %d", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld %lld %lld", &a, &b, &c, &t);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &arr[i]);
         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -