QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#326807 | #5585. Creative Accounting | adamk | WA | 1ms | 3584kb | C++14 | 1.4kb | 2024-02-14 05:44:31 | 2024-02-14 05:44:32 |
Judging History
answer
#include <iostream>
#include <vector>
#include <climits>
using namespace std;
pair<int, int> count_profitable_segments(const vector<int>& profits, int min_segment_size, int max_segment_size) {
int n = profits.size();
int min_profitable_segments = INT_MAX;
int max_profitable_segments = 0;
for (int segment_size = min_segment_size; segment_size <= max_segment_size; segment_size++) {
for (int start_day = 0; start_day <= n - segment_size; start_day++) {
int total_profit = 0;
for (int i = start_day; i < start_day + segment_size; i++) {
total_profit += profits[i];
}
if (total_profit > 0) {
min_profitable_segments = min(min_profitable_segments, n / segment_size);
max_profitable_segments = max(max_profitable_segments, (n + segment_size - 1) / segment_size);
}
}
}
return {min_profitable_segments, max_profitable_segments};
}
int main() {
int n, min_segment_size, max_segment_size;
cin >> n >> min_segment_size >> max_segment_size;
vector<int> profits(n);
for (int i = 0; i < n; i++) {
cin >> profits[i];
}
pair<int, int> result = count_profitable_segments(profits, min_segment_size, max_segment_size);
cout << result.first << " " << result.second << endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3576kb
input:
10 3 5 3 2 -7 5 4 1 3 0 -3 5
output:
2 4
result:
ok single line: '2 4'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1 1 1 1
output:
1 1
result:
ok single line: '1 1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
3 1 3 3 3 3
output:
1 3
result:
ok single line: '1 3'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3532kb
input:
10 1 5 0 0 0 0 0 0 0 0 0 0
output:
2147483647 0
result:
wrong answer 1st lines differ - expected: '0 0', found: '2147483647 0'