Submission #1604891
Source Code Expand
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; int d[51][51]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> d[i][j]; } } int q; cin >> q; vector<int> p(q); for (int i = 0; i < q; i++) { cin >> p[i]; } int c[51][51] = {}; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { c[i][j] = d[i - 1][j - 1] + c[i - 1][j] + c[i][j - 1] - c[i - 1][j - 1]; } } for (int i = 0; i < q; i++) { int ans = 0; for (int j = 1; j <= min(n, p[i]); j++) { int h = j, w = min(n, p[i] / j); for (int k = 1; k + h - 1 <= n; k++) { for (int l = 1; l + w - 1 <= n; l++) { ans = max(ans, c[k + h - 1][l + w - 1] - c[k + h - 1][l - 1] - c[k - 1][l + w - 1] + c[k - 1][l - 1]); } } } cout << ans << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - おいしいたこ焼きの焼き方 |
User | legosuke |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 929 Byte |
Status | AC |
Exec Time | 68 ms |
Memory | 256 KB |
Judge Result
Set Name | Subtask1 | Subtask2 | ||||
---|---|---|---|---|---|---|
Score / Max Score | 50 / 50 | 50 / 50 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Subtask1 | sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt, s1.txt, s2.txt, sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt |
Subtask2 | rand0.txt, rand1.txt, rand2.txt, rand3.txt, rand4.txt, rand_max0.txt, rand_max1.txt, rand_max2.txt, rand_max3.txt, rand_max4.txt, s1.txt, s2.txt, sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
rand0.txt | AC | 6 ms | 256 KB |
rand1.txt | AC | 12 ms | 256 KB |
rand2.txt | AC | 29 ms | 256 KB |
rand3.txt | AC | 3 ms | 256 KB |
rand4.txt | AC | 1 ms | 256 KB |
rand_max0.txt | AC | 68 ms | 256 KB |
rand_max1.txt | AC | 63 ms | 256 KB |
rand_max2.txt | AC | 65 ms | 256 KB |
rand_max3.txt | AC | 64 ms | 256 KB |
rand_max4.txt | AC | 67 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
sub0.txt | AC | 1 ms | 256 KB |
sub1.txt | AC | 1 ms | 256 KB |
sub2.txt | AC | 1 ms | 256 KB |
sub_rand_max0.txt | AC | 1 ms | 256 KB |
sub_rand_max1.txt | AC | 1 ms | 256 KB |
sub_rand_max2.txt | AC | 1 ms | 256 KB |
sub_rand_max3.txt | AC | 1 ms | 256 KB |
sub_rand_min0.txt | AC | 1 ms | 256 KB |