Submission #538958

# Submission time Handle Problem Language Result Execution time Memory
538958 2022-03-18T05:57:08 Z ryangohca Popeala (CEOI16_popeala) C++17
17 / 100
2000 ms 2260 KB
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define ti3 tuple<int, int, int>
#define ti4 tuple<int, int, int, int>
// This is like my secret account; yes it's like that  ~ Baek Jiheon, Feel Good (Secret Code)
using namespace std;
int psum[20001];
int psumt[51][20001];
int n;
string results[51];
int cost(int l, int r){
    int score = psum[r] - psum[l-1];
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (psumt[i][r] - psumt[i][l-1] == r-l+1) ans += score;
    }
    return ans;
}
int dp[20001][51];
main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t, s; cin >> n >> t >> s;
    for (int i = 1; i <= t; i++){
        cin >> psum[i];
        psum[i] += psum[i-1];
    }
    for (int i = 0; i < n; i++){
        for (int j = 1; j <= t; j++){
            char x; cin >> x;
            int g = x - '0';
            psumt[i][j] = g;
            psumt[i][j] += psumt[i][j-1];
        }
    }
    dp[0][0] = 0;
    for (int i = 1; i <= t; i++){
        dp[i][0] = 1e15;
    }
    for (int i = 1; i <= s; i++){
        dp[0][i] = 1e15;
        for (int j = 1; j <= t; j++){
            dp[j][i] = 1e15;
            for (int k = 0; k < j; k++){
                dp[j][i] = min(dp[j][i], dp[k][i-1] + cost(k+1, j));
            }
        }
        cout << dp[t][i] << '\n';
    }
}

Compilation message

popeala.cpp:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 337 ms 956 KB Output is correct
2 Correct 332 ms 976 KB Output is correct
3 Correct 330 ms 956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2081 ms 2260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 337 ms 956 KB Output is correct
4 Correct 332 ms 976 KB Output is correct
5 Correct 330 ms 956 KB Output is correct
6 Execution timed out 2081 ms 2260 KB Time limit exceeded
7 Halted 0 ms 0 KB -