답안 #299321

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
299321 2020-09-14T17:39:12 Z BeanZ Semiexpress (JOI17_semiexpress) C++14
48 / 100
8 ms 1152 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define endl '\n'
const int N = 1e5 + 5;
ll dp[305][305];
ll s[305], len[305], p[305], last[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;
        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 = 1; i <= n; i++){
                last[i] = cur;
                if ((cur + 1) <= m && s[cur + 1] <= i) cur++;
                len[i] = (s[cur] - 1) * B + (i - s[cur]) * C;
                ll dist = len[i];
                if (dist <= T) p[i] = 1;
                else p[i] = 0;
                for (int j = i + 1; j <= n; j++){
                        dist = dist + A;
                        if (dist > T) break;
                        p[i]++;
                }
                //cout << last[i] << " " << p[i] << endl;
        }
        //cout << endl << endl;
        ll ans = 0;
        for (int i = 1; i <= n; i++){
                for (int j = 0; j <= k; j++) dp[i][j] = -1e9;
        }
        ll cnt = 1;
        dp[1][1] = p[1];
        for (int i = 2; i <= n; i++){
                cnt += st[i];
                for (int j = 1; j <= (cnt + (k - m)); j++){
                        for (int t = s[last[i]]; t < i; t++){
                                dp[i][j] = max(dp[i][j], dp[t][j - 1] - p[t] + min((ll)(i - t), p[t]) + p[i]);
                                ans = max(ans, dp[i][j]);
                                //cout << i << " " << j << " " << dp[i][j] << endl;
                        }
                }
        }
        cout << ans - 1;
}
/*
eraae
*/

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 1 ms 1024 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 1 ms 1024 KB Output is correct
4 Correct 1 ms 1024 KB Output is correct
5 Correct 1 ms 1024 KB Output is correct
6 Correct 1 ms 1056 KB Output is correct
7 Correct 2 ms 1024 KB Output is correct
8 Correct 2 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1024 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 1 ms 1024 KB Output is correct
4 Correct 1 ms 1024 KB Output is correct
5 Correct 1 ms 1024 KB Output is correct
6 Correct 1 ms 1056 KB Output is correct
7 Correct 2 ms 1024 KB Output is correct
8 Correct 2 ms 1152 KB Output is correct
9 Correct 3 ms 1024 KB Output is correct
10 Correct 8 ms 1024 KB Output is correct
11 Correct 4 ms 1024 KB Output is correct
12 Correct 2 ms 1024 KB Output is correct
13 Correct 2 ms 1024 KB Output is correct
14 Correct 1 ms 1024 KB Output is correct
15 Correct 1 ms 1152 KB Output is correct
16 Correct 1 ms 1024 KB Output is correct
17 Correct 2 ms 1152 KB Output is correct
18 Correct 3 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1024 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 1 ms 1024 KB Output is correct
4 Correct 1 ms 1024 KB Output is correct
5 Correct 1 ms 1024 KB Output is correct
6 Correct 1 ms 1056 KB Output is correct
7 Correct 2 ms 1024 KB Output is correct
8 Correct 2 ms 1152 KB Output is correct
9 Correct 3 ms 1024 KB Output is correct
10 Correct 8 ms 1024 KB Output is correct
11 Correct 4 ms 1024 KB Output is correct
12 Correct 2 ms 1024 KB Output is correct
13 Correct 2 ms 1024 KB Output is correct
14 Correct 1 ms 1024 KB Output is correct
15 Correct 1 ms 1152 KB Output is correct
16 Correct 1 ms 1024 KB Output is correct
17 Correct 2 ms 1152 KB Output is correct
18 Correct 3 ms 1024 KB Output is correct
19 Runtime error 1 ms 512 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -