# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
97521 | popovicirobert | 조교 (CEOI16_popeala) | C++14 | 523 ms | 28700 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44
using namespace std;
const ll INF = 1e15;
const int MAXN = 50;
const int MAXT = 20000;
int pts[MAXT + 1], sp[MAXT + 1];
char res[MAXN + 1][MAXT + 1];
int ind[MAXN + 1][MAXT + 1];
ll dp[2][MAXT + 1];
ll mn[2][MAXN + 1][MAXT + 1];
int main() {
//ifstream cin("A.in");
//ofstream cout("A.out");
int i, j, n, t, s;
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> t >> s;
for(i = 1; i <= t; i++) {
cin >> pts[i];
sp[i] = sp[i - 1] + pts[i];
}
for(i = 1; i <= n; i++) {
cin >> res[i] + 1;
for(j = 1; j <= t; j++) {
res[i][j] -= '0';
if(res[i][j] == 0) {
ind[i][j] = j;
}
else {
ind[i][j] = ind[i][j - 1];
}
}
}
vector < vector <int> > pos(t + 1);
for(i = 1; i <= t; i++) {
for(j = 1; j <= n; j++) {
pos[i].push_back(ind[j][i]);
}
sort(pos[i].begin(), pos[i].end());
pos[i].push_back(i);
}
dp[0][0] = 0;
for(j = 1; j <= t; j++) {
dp[0][j] = INF;
}
for(int k = 1; k <= s; k++) {
for(i = 0; i <= n; i++) {
mn[1 - k & 1][i][0] = dp[1 - k & 1][0];
for(j = 1; j <= t; j++) {
mn[1 - k & 1][i][j] = min(mn[1 - k & 1][i][j - 1], dp[1 - k & 1][j] - sp[j] * i);
}
}
dp[k & 1][0] = INF;
for(j = 1; j <= t; j++) {
dp[k & 1][j] = INF;
for(i = 0; i < pos[j].size(); i++) {
if(pos[j][i] > 0) {
dp[k & 1][j] = min(dp[k & 1][j], mn[1 - k & 1][i][pos[j][i] - 1] + sp[j] * i);
//cerr << pos[j][i] << " ";
}
}
//cerr << " ";
//cerr << dp[k & 1][j] << " ";
}
//cerr << "\n";
cout << dp[k & 1][t] << "\n";
}
//cin.close();
//cout.close();
return 0;
}
컴파일 시 표준 에러 (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... |