Submission #3979373


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;

	rep(i, 0, q) {
		ll p; cin >> p;
		ll v = 0;
		repe(i, 1, n)repe(j, 1, n)repe(k, i, n)repe(l, j, n) {
			if (p >= (k - i + 1)*(l - j + 1)) {
				v = max(v, s[k][l] + s[i - 1][j - 1] - s[k][j - 1] - s[i - 1][l]);
			}
		}
		cout << v << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User butanokakuni_c1
Language C++14 (GCC 5.4.1)
Score 50
Code Size 923 Byte
Status TLE
Exec Time 5255 ms
Memory 256 KB

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 50 / 50 0 / 50
Status
AC × 18
AC × 15
TLE × 5
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 329 ms 256 KB
rand1.txt AC 649 ms 256 KB
rand2.txt AC 2199 ms 256 KB
rand3.txt AC 70 ms 256 KB
rand4.txt AC 2 ms 256 KB
rand_max0.txt TLE 5255 ms 256 KB
rand_max1.txt TLE 5255 ms 256 KB
rand_max2.txt TLE 5255 ms 256 KB
rand_max3.txt TLE 5255 ms 256 KB
rand_max4.txt TLE 5255 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