# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
153041 | 2019-09-11T15:04:55 Z | Mercenary | 조교 (CEOI16_popeala) | C++14 | 219 ms | 209272 KB |
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> #define pb push_back #define mp make_pair #define taskname "A" using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int,int> ii; typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; const int maxn = 2e4 + 5; int dp[maxn][51] , dp1[maxn][51][51]; int n , s , t; int pre[maxn][51]; vector<int> v[maxn]; int point[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP", "r",stdin); freopen(taskname".OUT", "w",stdout); } fill_n(&dp[0][0],maxn*51,2e9); fill_n(&dp1[0][0][0],maxn*51*51,2e9); cin >> n >> t >> s; for(int i = 1 ; i <= t ; ++i){ cin >> point[i]; point[i] += point[i - 1]; } for(int i = 0 ; i < n ; ++i){ string s;cin >> s; for(int j = 1 ; j <= t ; ++j){ if(s[j - 1] == '1')pre[i][j] = pre[i][j - 1]; else pre[i][j] = j; v[j].pb(pre[i][j]); } } dp[0][0] = 0; for(int i = 0 ; i <= n ; ++i){ dp1[0][0][i] = 0; } for(int i = 1 ; i <= t ; ++i){ v[i].pb(0);v[i].pb(i); sort(v[i].begin(),v[i].end(),greater<int>()); // for(int c : v[i])cout << c << " ";cout << endl; for(int j = 1 ; j <= s ; ++j){ for(int c = 0 ; c <= n ; ++c){ // for(int id = v[i][c] ; id > v[i][c + 1] && id >= 1 ; --id){ //// cout << i << " " << j << " " << n - c << " " << id << endl; // dp[i][j] = min(dp[i][j] , dp1[id - 1][j - 1][n - c] + (n - c) * point[i]); // } if(v[i][c] >= 1)dp[i][j] = min(dp[i][j] , dp1[v[i][c] - 1][j - 1][n - c] + (n - c) * point[i]); } } for(int j = 0 ; j <= s ; ++j){ for(int c = 0 ; c <= n ; ++c){ dp1[i][j][c] = min(dp1[i - 1][j][c] , dp[i][j] - c * point[i]); } } } for(int j = 1 ; j <= s ; ++j){ cout << dp[t][j] << '\n'; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 209 ms | 208436 KB | Output is correct |
2 | Correct | 181 ms | 208704 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 187 ms | 208888 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 219 ms | 209272 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 209 ms | 208436 KB | Output is correct |
2 | Correct | 181 ms | 208704 KB | Output is correct |
3 | Incorrect | 187 ms | 208888 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |