Submission #1803174
Source Code Expand
#include <bits/stdc++.h>
#ifndef LOCAL
#define cerr dolor_sit_amet
#endif
#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1, 0, -1, 0, 1, -1, 1, -1};
const int DY[] = { 0, 1, 0, -1, 1, -1, -1, 1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }
// ========================================================================= //
const int N = 55;
int n;
int a[N];
int main() {
ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i];
sort(a + 1, a + n + 1);
if (a[1] == 0) {
cout << "0\n";
return 0;
}
for (int i = 1; i < n - 1; ++i)
if (a[i] == a[i+2]) {
cout << "0\n";
return 0;
}
if (n >= 2 && a[n-1] == 12) {
cout << "0\n";
return 0;
}
if (n == 23) {
cout << "1\n";
return 0;
}
int ans = 0;
for (int m = 0; m < 1 << n; ++m) {
static vector<int> ts;
int cans = 222;
int prv = 0;
for (int i = 1; i <= n; ++i)
if (m & (1 << (i-1))) {
cans = min(cans, a[i] - prv);
prv = a[i];
}
for (int i = n; i >= 1; --i)
if (!(m & (1 << (i-1)))) {
cans = min(cans, 24 - a[i] - prv);
prv = 24 - a[i];
}
cans = min(cans, 24 - prv);
ans = max(ans, cans);
}
cout << ans << "\n";
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Time Gap |
| User | SpyCheese |
| Language | C++14 (GCC 5.4.1) |
| Score | 500 |
| Code Size | 2215 Byte |
| Status | AC |
| Exec Time | 2 ms |
| Memory | 256 KiB |
Judge Result
| Set Name | sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| sample | sample-01.txt, sample-02.txt, sample-03.txt |
| All | sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, 01-41.txt, 01-42.txt, 01-43.txt, sample-01.txt, sample-02.txt, sample-03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01-01.txt | AC | 1 ms | 256 KiB |
| 01-02.txt | AC | 1 ms | 256 KiB |
| 01-03.txt | AC | 1 ms | 256 KiB |
| 01-04.txt | AC | 1 ms | 256 KiB |
| 01-05.txt | AC | 1 ms | 256 KiB |
| 01-06.txt | AC | 1 ms | 256 KiB |
| 01-07.txt | AC | 1 ms | 256 KiB |
| 01-08.txt | AC | 1 ms | 256 KiB |
| 01-09.txt | AC | 1 ms | 256 KiB |
| 01-10.txt | AC | 1 ms | 256 KiB |
| 01-11.txt | AC | 1 ms | 256 KiB |
| 01-12.txt | AC | 1 ms | 256 KiB |
| 01-13.txt | AC | 1 ms | 256 KiB |
| 01-14.txt | AC | 1 ms | 256 KiB |
| 01-15.txt | AC | 1 ms | 256 KiB |
| 01-16.txt | AC | 1 ms | 256 KiB |
| 01-17.txt | AC | 1 ms | 256 KiB |
| 01-18.txt | AC | 1 ms | 256 KiB |
| 01-19.txt | AC | 1 ms | 256 KiB |
| 01-20.txt | AC | 1 ms | 256 KiB |
| 01-21.txt | AC | 1 ms | 256 KiB |
| 01-22.txt | AC | 1 ms | 256 KiB |
| 01-23.txt | AC | 1 ms | 256 KiB |
| 01-24.txt | AC | 1 ms | 256 KiB |
| 01-25.txt | AC | 1 ms | 256 KiB |
| 01-26.txt | AC | 1 ms | 256 KiB |
| 01-27.txt | AC | 1 ms | 256 KiB |
| 01-28.txt | AC | 1 ms | 256 KiB |
| 01-29.txt | AC | 1 ms | 256 KiB |
| 01-30.txt | AC | 1 ms | 256 KiB |
| 01-31.txt | AC | 1 ms | 256 KiB |
| 01-32.txt | AC | 1 ms | 256 KiB |
| 01-33.txt | AC | 1 ms | 256 KiB |
| 01-34.txt | AC | 1 ms | 256 KiB |
| 01-35.txt | AC | 1 ms | 256 KiB |
| 01-36.txt | AC | 1 ms | 256 KiB |
| 01-37.txt | AC | 1 ms | 256 KiB |
| 01-38.txt | AC | 2 ms | 256 KiB |
| 01-39.txt | AC | 1 ms | 256 KiB |
| 01-40.txt | AC | 1 ms | 256 KiB |
| 01-41.txt | AC | 1 ms | 256 KiB |
| 01-42.txt | AC | 1 ms | 256 KiB |
| 01-43.txt | AC | 1 ms | 256 KiB |
| sample-01.txt | AC | 1 ms | 256 KiB |
| sample-02.txt | AC | 1 ms | 256 KiB |
| sample-03.txt | AC | 1 ms | 256 KiB |