Submission #8897826
Source Code Expand
#include <bits/stdc++.h> #define ls (o << 1) #define rs (o << 1 | 1) #define mid ((L + R) >> 1) using namespace std; typedef long long LL; const int N = 100500; const int mod = 1e9 + 7; int a[N], b[N], n; int main() { #ifdef TEST freopen("input.txt", "r", stdin); #endif scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); } sort(a, a + n); int m = 1; b[m - 1] = 1; for (int i = 1; i < n; ++i) { if (a[i] != a[i - 1]) { if (b[m - 1] == 1) { a[m - 1] = a[i]; b[m - 1] = 0; } else { a[m++] = a[i]; } } b[m - 1]++; } if (b[m - 1] == 1) m--; long long ans = 0; for (int i = m - 1; i >= 0; --i) { if (b[i] > 4) { ans = max(ans, 1LL * a[i] * a[i]); } } if (m > 1) { ans = max(ans, 1LL * a[m - 1] * a[m - 2]); } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Make a Rectangle |
User | kp600168 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 852 Byte |
Status | AC |
Exec Time | 20 ms |
Memory | 768 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:14:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:16:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &a[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, 1.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
1.txt | AC | 20 ms | 768 KB |
2.txt | AC | 8 ms | 384 KB |
3.txt | AC | 19 ms | 640 KB |
4.txt | AC | 20 ms | 768 KB |
5.txt | AC | 8 ms | 384 KB |
6.txt | AC | 15 ms | 640 KB |
7.txt | AC | 15 ms | 640 KB |
8.txt | AC | 7 ms | 384 KB |
9.txt | AC | 10 ms | 384 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |