답안 #153046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
153046 2019-09-11T15:31:22 Z Mercenary 조교 (CEOI16_popeala) C++14
0 / 100
251 ms 262148 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;

ll 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,1e18);
    fill_n(&dp1[0][0][0],maxn*51*51,1e18);
    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';
    }
}

Compilation message

popeala.cpp: In function 'int main()':
popeala.cpp:31:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".INP", "r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
popeala.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".OUT", "w",stdout);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 251 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 208 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 210 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 251 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -