Submission #538965

#TimeUsernameProblemLanguageResultExecution timeMemory
538965ryangohcaPopeala (CEOI16_popeala)C++17
0 / 100
82 ms2236 KiB
#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]; void dnc(int s, int e, int x, int y, int k){ int m = (s+e)/2; dp[m][k] = 1e15; pii opt = {1e15, 0}; for (int i = x; i <= min(y, m-1); i++){ opt = min(opt, {dp[i][k-1] + cost(i+1, m), i}); } dp[m][k] = opt.first; if (s < m) dnc(s, m - 1, x, opt.second, k); if (m < e) dnc(m+1, e, opt.second, y, k); } 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)); } } */ dnc(0, t, 0, t, i); cout << dp[t][i] << '\n'; } }

Compilation message (stderr)

popeala.cpp:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...