Submission #7472878


Source Code Expand

Copy
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<vector<int>> d(n,vector<int>(n));
    rep(i,n) rep(j,n) cin>>d[i][j];
    
    vector<vector<int>> s(n+1,vector<int>(n+1,0));
    rep(i,n) rep(j,n){
        s[i+1][j+1]=s[i][j+1]+s[i+1][j]-s[i][j]+d[i][j];
    }
    
    int q;
    cin>>q;
    vector<int> p(q);
    rep(i,q) cin>>p[i];
    
    rep(i,q){
        int ans=0;
        FOR(x,1,n){
            FOR(y,1,n){
                if(x*y>p[i]) continue;
            
                rep(u,n-x+1){
                    rep(v,n-y+1){
                        int nx=x+u;
                        int ny=y+v;
                        ans=max(ans,s[nx][ny]-s[u][ny]-s[nx][v]+s[u][v]);
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
    
}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User gyouzasushi
Language C++14 (GCC 5.4.1)
Score 50
Code Size 1217 Byte
Status
Exec Time 5255 ms
Memory 384 KB

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 50 / 50 0 / 50
Status
× 18
× 15
× 5
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 266 ms 256 KB
rand1.txt 526 ms 256 KB
rand2.txt 1787 ms 256 KB
rand3.txt 56 ms 256 KB
rand4.txt 2 ms 256 KB
rand_max0.txt 5189 ms 256 KB
rand_max1.txt 5255 ms 384 KB
rand_max2.txt 5222 ms 256 KB
rand_max3.txt 5255 ms 256 KB
rand_max4.txt 5192 ms 256 KB
s1.txt 1 ms 256 KB
s2.txt 1 ms 256 KB
sub0.txt 1 ms 256 KB
sub1.txt 1 ms 256 KB
sub2.txt 1 ms 256 KB
sub_rand_max0.txt 1 ms 256 KB
sub_rand_max1.txt 1 ms 256 KB
sub_rand_max2.txt 1 ms 256 KB
sub_rand_max3.txt 1 ms 256 KB
sub_rand_min0.txt 1 ms 256 KB