제출 #68403

#제출 시각아이디문제언어결과실행 시간메모리
68403BTheroSemiexpress (JOI17_semiexpress)C++17
48 / 100
160 ms1048 KiB
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)3e2 + 5;

int dp[MAXN][MAXN];

bool good[MAXN];

int p[MAXN];

int n, m, k;

ll a, b, c;

ll lim;

void solve() {                   
	scanf("%d %d %d", &n, &m, &k);
	scanf("%lld %lld %lld", &a, &b, &c);
	scanf("%lld", &lim);

    for (int i = 1, x; i <= m; ++i) {
		scanf("%d", &x);
		good[x] = 1;    
    }

    for (int i = 1, v = 1; i <= n; ++i) {
    	if (good[i]) {
    		v = i;
    	}

    	p[i] = v;
    }

    for (int i = 1; i <= n; ++i) {
    	for (int j = 1; j <= k; ++j) {
    		dp[i][j] = -n;
    	}
    }

    dp[1][1] = 0;

    for (int i = 2; i <= n; ++i) {
    	for (int j = 2; j <= k; ++j) {
    		for (int pr = p[i - 1]; pr < i; ++pr) {
				ll cost = (p[i - 1] - 1) * b + (pr - p[i - 1]) * c;
				int cnt = 0;

				for (int x = pr + 1; x < i; ++x) {
					if (cost + (x - pr) * a <= lim) {
						++cnt;
					}
				}

				if (good[i]) {
					if ((i - 1) * b <= lim) {
						++cnt;
					}
				}
				else {
				 	if (cost + (i - pr) * c <= lim) {
				 		++cnt;
				 	}
				}			

				dp[i][j] = max(dp[i][j], dp[pr][j - 1] + cnt);
    		}
    	}
    }

    printf("%d\n", dp[n][k]);
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

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

semiexpress.cpp: In function 'void solve()':
semiexpress.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &m, &k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld", &a, &b, &c);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &lim);
  ~~~~~^~~~~~~~~~~~~~
semiexpress.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...