Skip to content

Commit 0240195

Browse files
committed
Update poi-17-containers.mdx
closes #2892
1 parent c148591 commit 0240195

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

solutions/platinum/poi-17-containers.mdx

+8-10
Original file line numberDiff line numberDiff line change
@@ -50,32 +50,30 @@ solutions.
5050
#define FOR(i, x, y) for (int i = x; i < y; i++)
5151
using namespace std;
5252

53-
const int k = 300;
53+
const int sqrt_n = 300;
5454
int containers[100001];
55-
int dp[100001 + k][k];
55+
int dp[100001 + sqrt_n][sqrt_n];
5656

5757
int main() {
5858
iostream::sync_with_stdio(false);
5959
cin.tie(0);
60-
int n, q;
61-
cin >> n >> q;
62-
while (q--) {
60+
int n, k;
61+
cin >> n >> k;
62+
while (k--) {
6363
int a, l, d;
6464
cin >> a >> l >> d;
65-
if (d >= k)
66-
FOR(i, 0, l) containers[a + i * d]++;
65+
if (d >= sqrt_n) FOR(i, 0, l) containers[a + i * d]++;
6766
else {
6867
dp[a][d]++;
6968
dp[a + (l * d)][d]--;
7069
}
7170
}
7271

73-
FOR(j, 1, k) FOR(i, j, n + 1) dp[i][j] += dp[i - j][j];
72+
FOR(j, 1, sqrt_n) FOR(i, j, n + 1) dp[i][j] += dp[i - j][j];
7473

7574
FOR(i, 1, n + 1) {
76-
FOR(j, 1, k) containers[i] += dp[i][j];
75+
FOR(j, 1, sqrt_n) containers[i] += dp[i][j];
7776
cout << containers[i] << ' ';
7877
}
79-
return 0;
8078
}
8179
```

0 commit comments

Comments
 (0)