Submission #1593338
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <map> #include <unordered_map> #include <set> #include <climits> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N, Q; cin >> N; vector<vector<int>> D(N+1, vector<int>(N+1, 0)), E(N+1, vector<int>(N+1, 0)); for(int i=1; i<=N; i++) for(int j=1; j<=N; j++) cin >> D[i][j]; for(int i=1; i<=N; i++) for(int j=1; j<=N; j++) E[i][j] = E[i][j-1] + D[i][j]; for(int j=1; j<=N; j++) for(int i=1; i<=N; i++) E[i][j] += E[i-1][j]; vector<int> v(N*N+1, 0); for(int i=0; i<=N; i++){ for(int j=0; j<=N; j++){ for(int k=i+1; k<=N; k++){ for(int l=j+1; l<=N; l++){ int S = (k-i)*(l-j); int T = E[k][l] - E[k][j] - E[i][l] + E[i][j]; v[S] = max(v[S], T); } } } } int a = 0; for(int i=1; i<=N*N; i++){ a = max(a, v[i]); v[i] = a; } cin >> Q; for(int k=0; k<Q; k++){ int P; cin >> P; cout << v[P] << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - おいしいたこ焼きの焼き方 |
User | suzume |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 1277 Byte |
Status | AC |
Exec Time | 8 ms |
Memory | 256 KB |
Judge Result
Set Name | Subtask1 | Subtask2 | ||||
---|---|---|---|---|---|---|
Score / Max Score | 50 / 50 | 50 / 50 | ||||
Status |
|
|
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 | 3 ms | 256 KB |
rand1.txt | AC | 3 ms | 256 KB |
rand2.txt | AC | 5 ms | 256 KB |
rand3.txt | AC | 2 ms | 256 KB |
rand4.txt | AC | 1 ms | 256 KB |
rand_max0.txt | AC | 8 ms | 256 KB |
rand_max1.txt | AC | 8 ms | 256 KB |
rand_max2.txt | AC | 8 ms | 256 KB |
rand_max3.txt | AC | 8 ms | 256 KB |
rand_max4.txt | AC | 8 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 |