Submission #1591005


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, q, d[55][55], s[55][55], dp[2505];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) cin >> d[i][j];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			s[i][j] = s[i-1][j] + s[i][j-1] - s[i-1][j-1] + d[i][j];
		}
	}
	for (int i = 1; i <= n*n; i++) {
		int ma = 0;
		for (int j = 1; j*j <= i; j++) {
			if (i%j == 0 && i/j <= n) {
				for (int x = 1; x+j-1 <= n; x++) {
					for (int y = 1; y+i/j-1 <= n; y++) {
						ma = max(ma, s[x+j-1][y+i/j-1]-s[x-1][y+i/j-1]-s[x+j-1][y-1]+s[x-1][y-1]);
					}
				}
				for (int x = 1; x+i/j-1 <= n; x++) {
					for (int y = 1; y+j-1 <= n; y++) {
						ma = max(ma, s[x+i/j-1][y+j-1]-s[x-1][y+j-1]-s[x+i/j-1][y-1]+s[x-1][y-1]);
					}
				}
			}
		}
		dp[i] = max(ma, dp[i-1]);
	}
	cin >> q;
	vector<int> ans(q);
	FOR(i, q) {
		int p;
		cin >> p;
		ans[i] = dp[p];
	}
	FOR(i, q) cout << ans[i] << endl;
	return 0;
}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User moguta
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1273 Byte
Status AC
Exec Time 9 ms
Memory 384 KB

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 50 / 50 50 / 50
Status
AC × 18
AC × 20
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 4 ms 256 KB
rand1.txt AC 4 ms 256 KB
rand2.txt AC 6 ms 256 KB
rand3.txt AC 2 ms 256 KB
rand4.txt AC 1 ms 256 KB
rand_max0.txt AC 9 ms 256 KB
rand_max1.txt AC 9 ms 256 KB
rand_max2.txt AC 9 ms 256 KB
rand_max3.txt AC 9 ms 384 KB
rand_max4.txt AC 9 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