Submission #1800619


Source Code Expand

#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n; cin>>n;
    vector<vector<int>>graph(n,vector<int>(n,0));
    vector<vector<int>>sum(n,vector<int>(n,0));
    rep(i,n)rep(j,n)cin>>graph[i][j];
    sum=graph;
    rep(i,n)rep(j,n-1)sum[i][j+1]+=sum[i][j];
    int dp[2501]={0};
    for(int x=0;x<n;x++){
        for(int y=0;y<n;y++){
            for(int xl=1;xl<=n;xl++){
                for(int yl=1;yl<=n;yl++){
                    if(x+xl>n||y+yl>n)continue;
                    int temp=0;
                    rep(k,yl)temp+=sum[y+k][x+xl-1]-(x?sum[y+k][x-1]:0);
                    cmax(dp[(xl)*(yl)],temp);
                }
            }
        }
    }
    rep(i,2501)if(i)cmax(dp[i], dp[i-1]);
    int m; cin>>m;
    rep(i,m){
        int index; cin>>index;
        cout<<dp[index]<<endl;
    }
}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User yebityon
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1527 Byte
Status AC
Exec Time 46 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 22 ms 256 KB
rand1.txt AC 13 ms 256 KB
rand2.txt AC 22 ms 256 KB
rand3.txt AC 5 ms 256 KB
rand4.txt AC 1 ms 256 KB
rand_max0.txt AC 46 ms 256 KB
rand_max1.txt AC 46 ms 256 KB
rand_max2.txt AC 46 ms 256 KB
rand_max3.txt AC 46 ms 256 KB
rand_max4.txt AC 46 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