답안 #299047

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
299047 2020-09-14T12:42:04 Z BeanZ Semiexpress (JOI17_semiexpress) C++14
18 / 100
3 ms 2432 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define endl '\n'
const int N = 1e5 + 5;
ll dp[305][3005][2];
ll s[3005], len[305];
bool st[305];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        if (fopen("A.inp", "r")){
                freopen("test.inp", "r", stdin);
                freopen("test.out", "w", stdout);
        }
        ll n, m, k;
        cin >> n >> m >> k;
        ll A, B, C;
        cin >> A >> B >> C;
        dp[1][1][1] = 1;
        ll T;
        cin >> T;
        for (int i = 1; i <= m; i++) cin >> s[i], st[s[i]] = 1;
        len[1] = 0;
        ll cur = 1;
        for (int i = 2; i <= n; i++){
                if ((cur + 1) <= m && s[cur + 1] <= i) cur++;
                len[i] = (s[cur] - 1) * B + (i - s[cur]) * C;
                //cout << len[i] << " ";
        }
        //cout << endl;
        ll cnt = 1;
        ll dist = 0;
        for (int t = 2; t <= n; t++){
                dist = dist + A;
                if (dist > T) break;
                dp[t][1][0] = max(dp[t][1][0], dp[1][1][1] + t - 1);
        }
        ll ans = 1;
        for (int i = 2; i <= n; i++){
                if (st[i]) cnt++;
                for (int j = cnt + (st[i] == 0); j <= (cnt + (k - m)); j++){
                        dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][0]);
                        dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][1]);
                        dist = len[i];
                        if (dist <= T) dp[i][j][1] = max(dp[i][j][1], max(dp[i - 1][j - 1][0], dp[i - 1][j - 1][1]) + 1);
                        for (int t = i + 1; t <= n; t++){
                                dist = dist + A;
                                if (dist > T) break;
                                dp[t][j][0] = max(dp[t][j][0], dp[i][j][1] + t - i);
                        }
                        ans = max(ans, dp[i][j][0]);
                        ans = max(ans, dp[i][j][1]);
                        //cout << i << " " << j << " " << dp[i][j][0] << " " << dp[i][j][1] << endl;
                }
        }
        //cout << len[10] << endl;
        //cout << len[8] << " ";
        //cout << dp[2][2][1] << endl;
        cout << ans - 1;
}
/*
*/

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:15:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   15 |                 freopen("test.inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:16:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   16 |                 freopen("test.out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 1 ms 1664 KB Output is correct
4 Correct 1 ms 1536 KB Output is correct
5 Correct 1 ms 1536 KB Output is correct
6 Correct 2 ms 1664 KB Output is correct
7 Correct 2 ms 1536 KB Output is correct
8 Correct 2 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 1 ms 1664 KB Output is correct
4 Correct 1 ms 1536 KB Output is correct
5 Correct 1 ms 1536 KB Output is correct
6 Correct 2 ms 1664 KB Output is correct
7 Correct 2 ms 1536 KB Output is correct
8 Correct 2 ms 1664 KB Output is correct
9 Correct 2 ms 1920 KB Output is correct
10 Correct 2 ms 2432 KB Output is correct
11 Correct 3 ms 2304 KB Output is correct
12 Correct 2 ms 1920 KB Output is correct
13 Correct 3 ms 2304 KB Output is correct
14 Incorrect 2 ms 1568 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 1 ms 1664 KB Output is correct
4 Correct 1 ms 1536 KB Output is correct
5 Correct 1 ms 1536 KB Output is correct
6 Correct 2 ms 1664 KB Output is correct
7 Correct 2 ms 1536 KB Output is correct
8 Correct 2 ms 1664 KB Output is correct
9 Correct 2 ms 1920 KB Output is correct
10 Correct 2 ms 2432 KB Output is correct
11 Correct 3 ms 2304 KB Output is correct
12 Correct 2 ms 1920 KB Output is correct
13 Correct 3 ms 2304 KB Output is correct
14 Incorrect 2 ms 1568 KB Output isn't correct
15 Halted 0 ms 0 KB -