Submission #340219


Source Code Expand

#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
#define rep(i,a,b) for(auto (i)=(a);(i)<(b);(i)++)
int N,Q,P,nn;
int rect[50][50][51][51];
int opt[2501];

int main(void){
	cin >> N;
	nn = N*N+1;
	rep(i, 0, N)rep(j, 0, N){
		cin >> rect[i][j][0][0];
		opt[1] = max(opt[1], rect[i][j][0][0]);
	}
	
	rep(h, 1, N){
		rep(i,0,N)
			rep(j, 0, N - h){
				rect[i][j][0][h] = rect[i][j][0][h - 1] + rect[i][j + h][0][0];
				opt[h+1] = max(opt[h+1], rect[i][j][0][h]);
			}
	}
	rep(h, 0, N){
		rep(w, 1, N){
			int area = (w + 1)*(h + 1);
			rep(i,0,N-w)
				rep(j, 0, N - h){
					rect[i][j][w][h] = rect[i][j][w - 1][h] + rect[i + w][j][0][h];
					opt[area] = max(opt[area], rect[i][j][w][h]);
				}
		}
	}
	rep(i, 1, nn)
		opt[i] = max(opt[i - 1], opt[i]);

	cin >> Q;
	rep(i, 0, Q){
		cin >> P;
		cout << opt[P] << endl;
	}

}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User btk15049
Language C++11 (GCC 4.8.1)
Score 100
Code Size 896 Byte
Status AC
Exec Time 182 ms
Memory 21560 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 99 ms 15572 KB
rand1.txt AC 74 ms 11316 KB
rand2.txt AC 86 ms 14776 KB
rand3.txt AC 41 ms 6200 KB
rand4.txt AC 29 ms 1560 KB
rand_max0.txt AC 160 ms 21556 KB
rand_max1.txt AC 159 ms 21560 KB
rand_max2.txt AC 182 ms 21552 KB
rand_max3.txt AC 165 ms 21560 KB
rand_max4.txt AC 179 ms 21560 KB
s1.txt AC 28 ms 952 KB
s2.txt AC 28 ms 952 KB
sub0.txt AC 26 ms 1040 KB
sub1.txt AC 29 ms 952 KB
sub2.txt AC 27 ms 948 KB
sub_rand_max0.txt AC 28 ms 952 KB
sub_rand_max1.txt AC 28 ms 1064 KB
sub_rand_max2.txt AC 28 ms 944 KB
sub_rand_max3.txt AC 29 ms 1072 KB
sub_rand_min0.txt AC 28 ms 920 KB