Submission #7590751


Source Code Expand

#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;

int main()
{
	int N, Q;
	cin >> N;
	vector<vector<int>> D(N + 1, vector<int>(N + 1));
	rep(i, N)rep(j, N)cin >> D[i + 1][j + 1];
	cin >> Q;
	vector<int> P(Q);
	rep(i, Q)cin >> P[i];

	// imos
	rep(h, N + 1)rep(w, N)D[h][w + 1] += D[h][w];
	rep(w, N + 1)rep(h, N)D[h + 1][w] += D[h][w];

	// imos2
	vector<int> imos(N*N + 1, 0);
	rep(l, N)REP(r, l + 1, N + 1)rep(u, N)REP(d, u + 1, N + 1) {
		int score = D[d][r] - D[d][l] - D[u][r] + D[u][l];
		int area = (d - u)*(r - l);
		imos[area] = max(imos[area], score);
	}
	rep(i, N*N)imos[i + 1] = max(imos[i + 1], imos[i]);

	// query
	for (auto q : P) {
		cout << imos[q] << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User toma25
Language C++14 (GCC 5.4.1)
Score 100
Code Size 827 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 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 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