# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
153047 | Mercenary | 조교 (CEOI16_popeala) | C++14 | 524 ms | 219248 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[51][maxn];
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(i);
sort(v[i].begin(),v[i].end(),greater<int>());
for(int j = 1 ; j <= s ; ++j){
for(int c = 0 ; c <= n ; ++c){
// cout << j << " " << id << " " << dp[id - 1][j - 1] << endl;
if(v[i][c] > 0)dp[i][j] = min(dp[i][j] , dp1[v[i][c] - 1][j - 1][n - c] + (n - c) * point[i]);
}
// cout << dp[i][j] << " \n"[j == s];
}
// break;
for(int j = 0 ; j <= s ; ++j){
for(int c = 0 ; c <= n ; ++c){
dp1[i][j][c] = min((ll)dp1[i - 1][j][c] , (ll)dp[i][j] - c * point[i]);
}
}
}
for(int j = 1 ; j <= s ; ++j){
cout << dp[t][j] << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |