답안 #920305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
920305 2024-02-02T12:35:46 Z Cookie 조교 (CEOI16_popeala) C++14
17 / 100
2000 ms 9816 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;

#define sz(a) (int)a.size()
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mpp make_pair
const ld PI = 3.14159265359, prec = 1e-9;;
using u128 = __uint128_t;
//const int x[4] = {1, 0, -1, 0};
//const int y[4] = {0, -1, 0, 1};
const ll mod = 1e6 + 3;
const int mxn = 2e6 + 69, mxq = 1e5 + 5, sq = 500, mxv = 1e6 + 5;
//const int base = (1 <<18);
const ll inf = 1e9 + 5, neg = -69420;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int x[9] = {0, 1, 1, -1, -1, 2, -2, 2, -2};
//const inty[9] = {0, 2, -2, 2, -2, 1, 1, -1, -1};


int n, t, s;
ll p[mxn + 1], prefp[mxn + 1], pref[51][mxn + 1], dp[mxn + 1][51];
bool ok[mxn + 1][51];
void ckmin(ll &a, ll b){
    a = min(a, b);
}
void solve(){
    cin >> n >> t >> s;
    for(int i = 1; i <= t; i++){
        cin >> p[i]; prefp[i] = prefp[i - 1] + p[i];
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= t; j++){
            char c; cin >> c;
            ok[i][j] = (c - '0');
            pref[i][j] = pref[i][j - 1] + ok[i][j];
        }
    }
    for(int i = 0; i <= t; i++){
        for(int j = 0; j <= s; j++){
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;
    for(int i = 1; i <= t; i++){
        for(int j = 1; j <= s; j++){
            for(int k = i; k >= 1; k--){
                int cnt = 0;
                for(int l = 1; l <= n; l++){
                    if(pref[l][i] - pref[l][k - 1] == i - k + 1){
                        cnt++;
                    }
                }

                ckmin(dp[i][j], dp[k - 1][j - 1] + cnt * (prefp[i] - prefp[k - 1]));
            }
            //cout << i << " " << j << " " << dp[i][j] << "\n";
        }
    }
    for(int i = 1; i <= s; i++){
        cout << dp[t][i] << "\n";
    }
}
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("COLLEGE.INP", "r", stdin);
    //freopen("COLLEGE.OUT", "w", stdout);
    int tt; tt = 1;
    while(tt--){
        solve();

    }
    return(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 2 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 264 ms 5212 KB Output is correct
2 Correct 266 ms 5200 KB Output is correct
3 Correct 269 ms 5200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2031 ms 9816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 2 ms 4700 KB Output is correct
3 Correct 264 ms 5212 KB Output is correct
4 Correct 266 ms 5200 KB Output is correct
5 Correct 269 ms 5200 KB Output is correct
6 Execution timed out 2031 ms 9816 KB Time limit exceeded
7 Halted 0 ms 0 KB -