Submission #20084696


Source Code Expand

#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = 3.14159265359;
const ll INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

ll d[51][51];

int main()
{
  int n;
  cin >> n;

  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= n; j++){
      cin >> d[i][j];
    }
  }

  int q;
  cin >> q;
  vector<int> p(q);
  for (int& x : p) cin >> x;

  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= n; j++){
      d[i][j] += d[i-1][j] + d[i][j-1] - d[i-1][j-1];
    }
  }

  vector<ll> ans(n*n+1);

  for(int y0 = 0; y0 < n; y0++){
    for(int y1 = y0+1; y1 <= n; y1++){
      for(int x0 = 0; x0 < n; x0++){
	for(int x1 = x0+1; x1 <= n; x1++){
	  ll area = (y1 - y0) * (x1 - x0);
	  ll taste = d[y1][x1] - d[y0][x1] - d[y1][x0] + d[y0][x0];
	  chmax(ans[area], taste);
	}
      }
    }
  }

  for (int i = 1; i < ans.size(); i++){
    chmax(ans[i], ans[i-1]);
  }
  
  for (int area : p){
    cout << ans[area] << endl;
  }
  return 0;
}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User unnohideyuki
Language C++ (GCC 9.2.1)
Score 100
Code Size 1166 Byte
Status AC
Exec Time 18 ms
Memory 3668 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:54:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   54 |   for (int i = 1; i < ans.size(); i++){
      |                   ~~^~~~~~~~~~~~

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 10 ms 3592 KiB
rand1.txt AC 7 ms 3480 KiB
rand2.txt AC 11 ms 3492 KiB
rand3.txt AC 4 ms 3512 KiB
rand4.txt AC 2 ms 3464 KiB
rand_max0.txt AC 15 ms 3480 KiB
rand_max1.txt AC 13 ms 3452 KiB
rand_max2.txt AC 13 ms 3628 KiB
rand_max3.txt AC 16 ms 3668 KiB
rand_max4.txt AC 18 ms 3476 KiB
s1.txt AC 2 ms 3456 KiB
s2.txt AC 3 ms 3620 KiB
sub0.txt AC 2 ms 3520 KiB
sub1.txt AC 2 ms 3428 KiB
sub2.txt AC 2 ms 3396 KiB
sub_rand_max0.txt AC 2 ms 3496 KiB
sub_rand_max1.txt AC 2 ms 3620 KiB
sub_rand_max2.txt AC 2 ms 3652 KiB
sub_rand_max3.txt AC 2 ms 3456 KiB
sub_rand_min0.txt AC 2 ms 3456 KiB