Submission #959527

#TimeUsernameProblemLanguageResultExecution timeMemory
959527vjudge1Semiexpress (JOI17_semiexpress)C++17
48 / 100
2 ms4956 KiB
#include <bits/stdc++.h> #define Y8o "Semiexpress" #define maxn 3005 #define ll long long #define pii pair<int, int> #define gb(i, j) ((i >> j) & 1) using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll GetRandom(ll l, ll r) { return uniform_int_distribution<ll> (l, r) (rng); } void iof() { if(fopen(Y8o".inp", "r")) { freopen(Y8o".inp", "r", stdin); // freopen(Y8o".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL); } void ctime() { cerr << "\n" << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; } int n, m, k; ll A, B, C, T; ll a[maxn]; ll sum[maxn][maxn]; /// sum[i][j] : số lượng nhiều nhất khi xét nhóm i, đặt j vt ll dp[maxn][maxn]; /// dp[i][j] : số lượng nhiều nhất khi xét đến nhóm i, đặt j vt void sub2() { for(int i = 1, cnt = 0; i <= m; i ++, cnt = 0) { ll val = (a[i] - 1) * B; if(val > T) break; ll val2 = val, pos = a[i + 1] - 1; for(int t = a[i] + 1; t <= a[i + 1] - 1; t ++) { val2 += A; if(val2 > T) { val2 = val + (t - a[i]) * C; if(val2 > T) { pos = t - 1; break; } sum[i][cnt ++] = (t - 1) - a[i] + 1 - (i == 1); } } sum[i][cnt] = pos - a[i] + 1 - (i == 1); if(i == m) sum[i][cnt] = 1; } for(int i = 1; i <= m; i ++) { for(int j = 0; j <= k; j ++) { for(int t = 0; t <= j; t ++) { dp[i][j] = max(dp[i][j], dp[i - 1][t] + sum[i][j - t]); } } } ll ans = 0; for(int t = 0; t <= k; t ++) ans = max(ans, dp[m][t]); cout << ans; } void solve() { cin >> n >> m >> k, k -= m; cin >> A >> B >> C >> T; for(int i = 1; i <= m; i ++) cin >> a[i]; if(n <= 1000000) sub2(); } int main() { iof(); int nTest = 1; // cin >> nTest; while(nTest --) { solve(); } ctime(); return 0; }

Compilation message (stderr)

semiexpress.cpp: In function 'void iof()':
semiexpress.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(Y8o".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...