제출 #581891

#제출 시각아이디문제언어결과실행 시간메모리
581891hibikiSemiexpress (JOI17_semiexpress)C++11
100 / 100
8 ms4548 KiB
#include<bits/stdc++.h>
using namespace std;

long long n,m,k;
long long a,b,c;
long long t,s[3005];
long long ans = 0;
priority_queue<long long> ex;

int main()
{
    scanf("%lld %lld %lld",&n,&m,&k);
    scanf("%lld %lld %lld",&a,&b,&c);
    scanf("%lld",&t);
    k -= m;
    for(int i = 0; i < m; i++)
        scanf("%lld",&s[i]);
    for(int i = 0; i < m; i++)
    {
        long long ti = (s[i] - 1) * b;
        if(ti > t) break;
        long long go = min(s[i] + (t - ti) / a, (i == m - 1)? n: (s[i + 1] - 1));
        // printf("a %lld %lld\n",s[i],go);
        ans += go - s[i] + 1;
        long long nw = go + 1;
        for(int j = 0; j < k && nw < ((i == m - 1)? (n + 1): s[i + 1]); j++)
        {
            long long ti2 = ti + (nw - s[i]) * c;
            if(ti2 > t) break;
            long long go2 = min(nw + (t - ti2) / a, (i == m - 1)? n: (s[i + 1] - 1));
            // printf("b %lld %lld\n",nw,go2);
            ex.push(go2 - nw + 1);
            nw = go2 + 1;
        }
    }
    while(!ex.empty() && k)
    {
        ans += ex.top();
        ex.pop();
        k--;
    }
    ans--;
    printf("%lld\n",ans);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%lld %lld %lld",&n,&m,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%lld %lld %lld",&a,&b,&c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%lld",&t);
      |     ~~~~~^~~~~~~~~~~
semiexpress.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld",&s[i]);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...