QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#713137 | #9563. 人间应又雪 | hos_lyric# | 2 | 82ms | 9452kb | C++14 | 2.7kb | 2024-11-05 18:15:48 | 2024-11-05 18:15:48 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
int TID;
int N, M, C;
vector<int> A;
namespace brute {
/*
yanhe : x[0],...,x[k]
tianyi: y[N-1],...,y[k]
s := \sum x[i]
t := \sum y[i]
fix t ~> x[0],...,x[k-1]: greedy
fix s ~> y[N-1],...,y[k+1]: greedy
*/
int pre[4010][4010];
int suf[4010][4010];
int run() {
for (int t = 0; t <= M; ++t) {
for (int i = 0; i < N; ++i) {
const int x = (max(A[i] - pre[t][i] - t, 0) + (C+1) - 1) / (C+1);
pre[t][i + 1] = pre[t][i] + x;
}
}
for (int s = 0; s <= M; ++s) {
for (int i = N; --i >= 0; ) {
const int y = (max(A[i] - s - suf[s][i + 1], 0) + (C+1) - 1) / (C+1);
suf[s][i] = y + suf[s][i + 1];
}
}
int ans = M;
for (int i = 0; i < N; ++i) {
for (int s = 0; s <= M; ++s) for (int t = 0; t <= M; ++t) {
const int x = s - pre[t][i];
const int y = t - suf[s][i + 1];
if (x >= 0 && y >= 0 && C * (x + y) >= A[i] - s - t) {
chmin(ans, s + t);
}
}
}
return ans;
}
} // brute
int main() {
for (int numCases; ~scanf("%d%d", &numCases, &TID); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
scanf("%d%d%d", &N, &M, &C);
A.resize(N);
for (int i = 0; i < N; ++i) {
scanf("%d", &A[i]);
}
int ans;
if (TID == 1) {
ans = *max_element(A.begin(), A.end());
} else {
ans = brute::run();
}
printf("%d\n", ans);
}
#ifndef LOCAL
break;
#endif
}
return 0;
}
詳細信息
Subtask #1:
score: 2
Accepted
Test #1:
score: 2
Accepted
time: 1ms
memory: 3948kb
input:
1000 1 9 8 0 8 5 2 1 6 4 5 1 5 9 8 0 1 7 3 2 0 8 5 1 0 8 9 0 3 8 7 3 2 4 9 9 8 9 0 8 3 9 3 9 8 3 4 9 10 0 0 9 5 5 4 3 6 10 5 8 8 0 3 5 1 6 8 4 2 5 8 9 0 5 2 3 8 1 4 2 9 10 8 0 2 8 2 3 1 7 0 1 5 1 8 9 0 1 0 4 9 9 5 7 2 9 10 0 3 4 0 10 0 9 6 7 0 8 9 0 4 8 4 4 0 4 2 3 9 8 0 0 5 2 3 1 0 4 0 0 10 10 0 3 ...
output:
8 8 9 9 10 8 9 8 9 10 8 5 10 9 8 8 7 10 8 10 8 10 9 8 10 6 10 8 8 6 7 8 9 7 9 8 8 8 5 8 9 10 5 8 10 8 10 7 9 9 9 8 8 7 9 9 8 9 8 8 7 8 8 7 10 9 10 9 9 8 8 9 7 8 9 7 7 9 6 10 8 7 8 8 9 9 9 9 9 8 8 5 7 8 8 9 6 8 8 9 8 9 8 9 9 10 8 9 8 8 7 8 7 8 7 7 7 10 9 10 9 9 8 9 8 10 10 8 7 10 8 10 8 8 8 7 10 10 8...
result:
ok 1000 lines
Test #2:
score: 2
Accepted
time: 56ms
memory: 8720kb
input:
2 1 499998 499999 0 301138 174092 254294 217002 447568 498904 49075 373725 308244 252462 370947 392908 319430 488362 86682 68848 435192 169516 29640 369208 128139 213960 159766 44498 322235 240582 283451 176399 270410 120552 173820 121114 197080 354767 283489 398040 13031 432699 251631 352577 264788...
output:
499999 499997
result:
ok 2 lines
Subtask #2:
score: 0
Wrong Answer
Test #3:
score: 3
Accepted
time: 1ms
memory: 3776kb
input:
1000 2 10 2 3 1 2 1 2 1 2 2 1 0 1 10 2 0 0 0 0 0 0 0 0 0 0 0 10 2 3 0 0 1 1 0 1 0 0 0 1 10 2 3 0 0 0 0 0 0 0 0 0 0 10 2 1 1 0 2 2 0 0 1 0 1 1 10 2 3 0 1 1 0 2 0 1 2 2 2 10 2 0 0 0 0 0 0 0 0 0 0 0 10 2 0 0 0 0 1 1 1 0 0 0 1 10 2 1 1 1 0 2 0 0 0 0 0 0 10 2 1 1 1 2 0 0 2 0 2 1 0 10 2 1 0 0 0 0 0 0 0 0 ...
output:
2 0 1 0 2 2 0 1 1 2 0 1 0 1 0 0 2 2 0 0 2 0 1 2 1 1 2 0 2 1 0 0 2 1 0 1 2 1 0 1 2 2 2 0 1 2 1 2 2 2 1 2 2 2 1 0 1 2 2 1 0 1 0 1 0 2 2 2 2 2 0 1 2 2 2 2 1 2 2 1 2 0 0 1 2 2 1 2 2 1 0 2 2 2 1 0 0 0 1 2 0 2 2 0 0 2 2 0 2 2 0 1 1 2 0 0 1 2 1 2 1 2 2 2 1 1 2 0 0 2 2 0 2 2 2 0 2 1 1 0 2 2 2 2 0 0 1 0 0 1 ...
result:
ok 1000 lines
Test #4:
score: 3
Accepted
time: 9ms
memory: 3916kb
input:
100 2 1000 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
0 1 1 2 1 0 1 1 2 0 0 0 0 0 0 1 0 2 2 2 1 2 1 1 1 2 2 2 0 2 1 1 2 0 0 1 2 0 0 0 0 2 2 2 1 1 2 2 0 0 2 1 2 1 2 2 0 2 0 0 0 2 2 0 2 0 0 2 1 2 1 2 0 1 0 2 1 1 2 2 2 2 2 2 0 2 2 1 2 2 0 1 2 1 1 0 0 0 0 2
result:
ok 100 lines
Test #5:
score: 0
Wrong Answer
time: 82ms
memory: 9452kb
input:
2 2 500000 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
0 2
result:
wrong answer 1st lines differ - expected: '1', found: '0'
Subtask #3:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 0ms
memory: 3908kb
input:
10 3 5 5 3 4 1 5 1 4 4 5 4 2 2 3 4 5 5 0 1 1 5 3 4 4 4 2 2 1 0 1 3 5 3 0 2 3 5 4 2 3 2 4 1 4 3 4 4 3 2 2 3 4 5 4 0 2 3 5 3 1 0 5 5 4 0 2 0 4 1 3
output:
3 3 5 4 4 3 2 2 2 4
result:
wrong answer 2nd lines differ - expected: '2', found: '3'
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Wrong Answer
Test #33:
score: 0
Wrong Answer
time: 71ms
memory: 4032kb
input:
5000 7 19 19 16 4 12 5 15 12 11 9 0 3 1 8 4 17 2 19 3 5 4 1 18 20 19 18 14 12 16 7 14 2 3 13 4 4 6 8 1 16 19 10 20 20 19 3 15 7 5 16 19 0 1 19 10 19 13 17 18 5 1 13 9 4 8 15 19 20 6 8 3 0 12 4 13 19 2 6 4 11 8 17 6 8 13 11 8 20 18 19 19 3 15 19 12 17 11 11 2 4 4 16 13 10 12 15 14 3 10 19 20 20 12 15...
output:
9 10 16 12 13 13 13 12 14 12 10 19 10 9 12 18 10 15 11 10 9 11 9 11 10 11 10 9 18 12 16 11 10 18 9 10 9 15 13 17 11 13 15 12 12 14 13 12 13 12 14 10 10 11 14 10 10 11 12 10 14 12 11 13 10 12 9 13 18 13 11 16 13 15 11 10 13 10 11 12 10 12 11 11 12 18 12 11 10 11 19 11 9 16 11 10 10 10 17 9 16 11 12 1...
result:
wrong answer 4th lines differ - expected: '11', found: '12'
Subtask #8:
score: 0
Skipped
Dependency #6:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #7:
0%
Subtask #10:
score: 0
Skipped
Dependency #2:
0%