Submission #3979398


Source Code Expand

#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;
static const ll MAX_L = (ll)1 << 62;

ll d[51][51] = {};
ll s[51][51] = {};

int main() {
	ll n; cin >> n;
	repe(i, 1, n)repe(j, 1, n)cin >> d[i][j];
	repe(i, 1, n)repe(j, 1, n) {
		s[i][j] += d[i][j] + s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
	}

	ll q; cin >> q;

	ll ans[2501] = {};
	repe(i, 1, n)repe(j, 1, n)repe(k, i, n)repe(l, j, n) {
		ll square = (k - i + 1)*(l - j + 1);
		ans[square] = max(ans[square], s[k][l] + s[i - 1][j - 1] - s[k][j - 1] - s[i - 1][l]);
	}

	rep(i, 1, 2501) {
		ans[i] = max(ans[i - 1], ans[i]);
	}
	rep(i, 0, q) {
		ll p; cin >> p;
		cout << ans[p] << endl;
	}

	return 0;
}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User butanokakuni_c1
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1011 Byte
Status AC
Exec Time 9 ms
Memory 256 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 2 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 256 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