AtCoder Beginner Contest 005

Submission #3979373

Source codeソースコード

#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

Task問題 D - おいしいたこ焼きの焼き方
User nameユーザ名 butanokakuni_c1
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 TLE
Score得点 50
Source lengthソースコード長 923 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Subtask1 50 / 50 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 0 / 50 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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
rand_max1.txt TLE
rand_max2.txt TLE
rand_max3.txt TLE
rand_max4.txt TLE
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