Submission #1443481
Source Code Expand
#include <iostream> #include <vector> #include <unordered_set> #include <unordered_map> #include <algorithm> using namespace std; using llng = long long; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; template<class T> using hset = unordered_set<T>; template<class Key, class T> using hmap = unordered_map<Key, T>; int main() { int N; cin >> N; vvi B(N+1, vi(N+1,0)); vi R(N*N+1, 0); int D; for (int i=1; i<=N; i++) for (int j=1; j<=N; j++) { cin >> D; B[i][j] = D + B[i-1][j] + B[i][j-1] - B[i-1][j-1]; } for (int i=0; i<=N; i++) { for (int j=0; j<=N; j++) { for (int di=1; i+di<=N; di++) { for (int dj=1; j+dj<=N; dj++) { R[di*dj] = max( R[di*dj], B[i+di][j+dj] - B[i][j+dj] - B[i+di][j] + B[i][j] ); } } } } int tmp = 0; for (int i=1; i<=N*N; i++) { if (tmp > R[i]) R[i] = tmp; else tmp = R[i]; } int Q; cin >> Q; for (int i=0; i<Q; i++) { int P; cin >> P; cout << R[P] << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - おいしいたこ焼きの焼き方 |
User | hidollara |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 1255 Byte |
Status | AC |
Exec Time | 9 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 | 4 ms | 256 KB |
rand1.txt | AC | 4 ms | 256 KB |
rand2.txt | AC | 6 ms | 256 KB |
rand3.txt | AC | 2 ms | 256 KB |
rand4.txt | AC | 1 ms | 256 KB |
rand_max0.txt | AC | 9 ms | 256 KB |
rand_max1.txt | AC | 9 ms | 256 KB |
rand_max2.txt | AC | 9 ms | 256 KB |
rand_max3.txt | AC | 9 ms | 256 KB |
rand_max4.txt | AC | 9 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 |