QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#96603 | #5585. Creative Accounting | PetroTarnavskyi# | AC ✓ | 99ms | 3644kb | C++17 | 1.0kb | 2023-04-14 17:10:59 | 2023-04-14 17:10:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int N = 1 << 15;
int a[N];
int pref[N];
int getSum(int l, int r) {
return pref[r] - (l == 0 ? 0 : pref[l - 1]);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, l, h;
cin >> n >> l >> h;
FOR(i, 0, n) {
cin >> a[i];
pref[i] = (i > 0 ? pref[i - 1] : 0) + a[i];
}
int mn = INT_MAX, mx = INT_MIN;
FOR(len, l, h + 1) {
for (int i = 0; i < len; i++) {
int c = 0;
if (i > 0 && pref[i - 1] > 0) {
c++;
}
for (int j = i; j < n; j += len) {
if (getSum(j, min(n, j + len) - 1) > 0) {
c++;
}
}
mn = min(mn, c);
mx = max(mx, c);
}
}
cout << mn << " " << mx << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3324kb
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: 2ms
memory: 3400kb
input:
1 1 1 1
output:
1 1
result:
ok single line: '1 1'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3196kb
input:
3 1 3 3 3 3
output:
1 3
result:
ok single line: '1 3'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3244kb
input:
10 1 5 0 0 0 0 0 0 0 0 0 0
output:
0 0
result:
ok single line: '0 0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
60 1 20 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -10000 -1000...
output:
0 0
result:
ok single line: '0 0'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3288kb
input:
5000 1 1 10000 9998 9996 9994 9992 9990 9988 9986 9984 9982 9980 9978 9976 9974 9972 9970 9968 9966 9964 9962 9960 9958 9956 9954 9952 9950 9948 9946 9944 9942 9940 9938 9936 9934 9932 9930 9928 9926 9924 9922 9920 9918 9916 9914 9912 9910 9908 9906 9904 9902 9900 9898 9896 9894 9892 9890 9888 9886 ...
output:
5000 5000
result:
ok single line: '5000 5000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3288kb
input:
5000 1 2 -10000 -9998 -9996 -9994 -9992 -9990 -9988 -9986 -9984 -9982 -9980 -9978 -9976 -9974 -9972 -9970 -9968 -9966 -9964 -9962 -9960 -9958 -9956 -9954 -9952 -9950 -9948 -9946 -9944 -9942 -9940 -9938 -9936 -9934 -9932 -9930 -9928 -9926 -9924 -9922 -9920 -9918 -9916 -9914 -9912 -9910 -9908 -9906 -9...
output:
0 0
result:
ok single line: '0 0'
Test #8:
score: 0
Accepted
time: 6ms
memory: 3328kb
input:
5000 1 500 0 1 -2 3 -4 5 -6 7 -8 9 -10 11 -12 13 -14 15 -16 17 -18 19 -20 21 -22 23 -24 25 -26 27 -28 29 -30 31 -32 33 -34 35 -36 37 -38 39 -40 41 -42 43 -44 45 -46 47 -48 49 -50 51 -52 53 -54 55 -56 57 -58 59 -60 61 -62 63 -64 65 -66 67 -68 69 -70 71 -72 73 -74 75 -76 77 -78 79 -80 81 -82 83 -84 85...
output:
2 2501
result:
ok single line: '2 2501'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3420kb
input:
5000 1 10 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 1...
output:
500 4998
result:
ok single line: '500 4998'
Test #10:
score: 0
Accepted
time: 2ms
memory: 3368kb
input:
5000 321 327 -10 3 0 -4 2 9 8 9 -10 -6 -8 -10 -10 9 6 2 3 -6 -4 -7 -1 -2 3 9 -2 3 0 0 4 -7 -2 6 1 8 0 -8 0 3 -5 0 -4 -2 1 5 -10 -2 7 -1 -8 2 6 9 -2 2 5 7 8 7 -3 3 8 -3 -7 -4 6 -4 4 1 6 7 -10 -8 5 -9 4 -2 8 -3 -8 -9 -7 7 -3 -4 8 5 -4 -7 0 5 1 6 -4 4 9 -9 1 0 4 -2 -4 -2 -10 9 4 9 7 -4 -6 9 9 6 7 3 -1 ...
output:
0 4
result:
ok single line: '0 4'
Test #11:
score: 0
Accepted
time: 2ms
memory: 3404kb
input:
5 1 3 -1 2 -1 2 -1
output:
1 2
result:
ok single line: '1 2'
Test #12:
score: 0
Accepted
time: 2ms
memory: 3240kb
input:
4 1 3 -100 1 2 -100
output:
0 2
result:
ok single line: '0 2'
Test #13:
score: 0
Accepted
time: 2ms
memory: 3200kb
input:
9 1 9 20 0 24 -2 -24 6 -9 25 -21
output:
1 4
result:
ok single line: '1 4'
Test #14:
score: 0
Accepted
time: 45ms
memory: 3480kb
input:
30000 3771 4739 4699 4697 4695 4693 4691 4689 4686 4684 4682 4680 4678 4676 4674 4671 4669 4667 4665 4662 4660 4658 4656 4653 4651 4649 4647 4644 4642 4639 4637 4635 4632 4630 4628 4625 4623 4620 4618 4615 4613 4610 4608 4605 4603 4600 4598 4595 4593 4590 4587 4585 4582 4580 4577 4574 4572 4569 4566...
output:
0 7
result:
ok single line: '0 7'
Test #15:
score: 0
Accepted
time: 20ms
memory: 3616kb
input:
30000 3167 3562 4845 4843 4840 4838 4835 4833 4830 4828 4826 4823 4820 4818 4815 4813 4810 4808 4805 4802 4800 4797 4794 4792 4789 4786 4783 4781 4778 4775 4772 4769 4767 4764 4761 4758 4755 4752 4749 4746 4743 4740 4737 4734 4731 4728 4725 4722 4719 4715 4712 4709 4706 4703 4700 4696 4693 4690 4686...
output:
0 9
result:
ok single line: '0 9'
Test #16:
score: 0
Accepted
time: 32ms
memory: 3644kb
input:
30000 734 1548 4714 4734 4754 4774 4794 4814 4833 4853 4872 4891 4910 4928 4947 4965 4983 5001 5019 5036 5054 5071 5088 5105 5122 5138 5155 5171 5187 5203 5218 5234 5249 5264 5279 5293 5308 5322 5336 5350 5364 5377 5391 5404 5417 5429 5442 5454 5467 5479 5490 5502 5513 5524 5535 5546 5557 5567 5577 ...
output:
11 38
result:
ok single line: '11 38'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3304kb
input:
20 4 12 -3 3 3 -3 10 8 -7 -8 6 -4 4 -7 -3 9 -5 8 -2 1 8 -4
output:
1 4
result:
ok single line: '1 4'
Test #18:
score: 0
Accepted
time: 2ms
memory: 3440kb
input:
20 8 15 9 7 6 2 1 -3 -6 -8 -6 10 -4 2 -6 2 -2 -8 -8 -5 -9 -8
output:
1 2
result:
ok single line: '1 2'
Test #19:
score: 0
Accepted
time: 2ms
memory: 3380kb
input:
20 6 13 -7 -3 10 2 5 -2 -3 6 3 8 -5 -9 -4 6 8 0 -8 -7 4 0
output:
1 3
result:
ok single line: '1 3'
Test #20:
score: 0
Accepted
time: 99ms
memory: 3516kb
input:
30000 29000 30000 2 0 2 5 -1 -1 -4 -4 0 -4 -1 0 0 -4 -2 4 4 0 0 -2 -4 -2 0 4 1 4 0 1 -1 0 -3 -4 -4 2 0 -4 2 -1 -2 0 -2 4 4 -3 2 2 0 2 3 0 -2 0 -3 2 3 -1 -3 1 4 -4 4 -3 4 4 0 1 0 0 0 -3 2 1 -1 5 3 3 -1 5 -2 4 -2 -4 5 -4 4 5 -4 -2 0 -1 4 0 -2 4 0 2 5 2 0 0 -3 -4 3 2 0 1 0 0 0 3 3 -3 -4 0 -1 2 3 -4 3 -...
output:
1 3
result:
ok single line: '1 3'