Submission #2150629
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using VS = vector<string>; using LL = long long;
using VI = vector<int>; using VVI = vector<VI>;
using PII = pair<int, int>; using PLL = pair<LL, LL>;
using VL = vector<LL>; using VVL = vector<VL>;
#define ALL(a) begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9; const LL LINF = 1e16;
const LL MOD = 1000000007; const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 }; int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
/* ----- 2018/03/03 Problem: code-festival-2017-final_c / Link: https://cf17-final.contest.atcoder.jp/tasks/cf17_final_c?lang=en ----- */
/* ------問題------
XXXX年のCODE FESTIVALには、世界中から高橋君を含めて N+1 人の参加者が集まりました。
高橋君の都市と他の N 人の都市の時刻の差を調べてみたところ、i 番目の人の都市との時刻の差は Di 時間でした。 ただし 2 つの都市について、片方の都市で 0 時の瞬間にもう一方の都市で d 時であるようなとき、これらの都市の時刻の差は min(d,24−d) であるものとします。 ここで、時刻の表記には 24 時間表記を用いるものとします。 つまり、例えば高橋君の都市で 0 時の瞬間には i 番目の人の都市は Di 時または 24−Di 時のいずれかとなります。
高橋君は次に、N+1 人のうちの全ての 2 人組についてその人の都市どうしの時刻の差を書き出し、それらの時刻の差のうちの最小値を s としました。
s として考えられる最大値を求めて下さい。
-----問題ここまで----- */
/* -----解説等-----
----解説ここまで---- */
LL N;
LL ans = 0LL;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
cin >> N;
VI a(N);
VI cnt(13, 0);
FOR(i, 0, N) {
cin >> a[i];
cnt[a[i]]++;
}
cnt[0]++;
FOR(i, 0, 13) {
if (cnt[i] > 2) {
cout << 0 << endl;
return 0;
}
}
if (cnt[0] > 1 || cnt[12] > 1) {
cout << 0 << endl;
return 0;
}
VI base(24, false);
base[0] = true;
if (cnt[12] == 1) {
base[12] = true;
}
FOR(i, 0, 13) {
if (cnt[i] == 2) {
base[i] = base[24 - i] = true;
}
}
ans = 0;
FOR(i, 0, (1 << 11)) {
VI used(48,0);
FOR(i, 0, 24) {
used[i] = base[i];
}
FOR(j, 0, 11) {
if (cnt[j + 1] != 1) continue;
if ((i >> j) & 1) {
used[j + 1] = true;
}
else {
used[24 - (j + 1)] = true;
}
}
FOR(j, 0, 24) used[j + 24] = used[j];
int l = 0;
int tans = INF;
FOR(r, 1, 48) {// 2周
if (used[r]) {
int t = min(r - l, 24 - (r - l));
tans = min(tans, t);
l = r;
}
}
ans = max(ans, (LL)tans);
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Time Gap |
User |
Yang33 |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
3300 Byte |
Status |
AC |
Exec Time |
2 ms |
Memory |
256 KB |
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 KB |
01-02.txt |
AC |
1 ms |
256 KB |
01-03.txt |
AC |
1 ms |
256 KB |
01-04.txt |
AC |
1 ms |
256 KB |
01-05.txt |
AC |
1 ms |
256 KB |
01-06.txt |
AC |
1 ms |
256 KB |
01-07.txt |
AC |
1 ms |
256 KB |
01-08.txt |
AC |
2 ms |
256 KB |
01-09.txt |
AC |
1 ms |
256 KB |
01-10.txt |
AC |
2 ms |
256 KB |
01-11.txt |
AC |
1 ms |
256 KB |
01-12.txt |
AC |
1 ms |
256 KB |
01-13.txt |
AC |
1 ms |
256 KB |
01-14.txt |
AC |
1 ms |
256 KB |
01-15.txt |
AC |
1 ms |
256 KB |
01-16.txt |
AC |
1 ms |
256 KB |
01-17.txt |
AC |
2 ms |
256 KB |
01-18.txt |
AC |
2 ms |
256 KB |
01-19.txt |
AC |
2 ms |
256 KB |
01-20.txt |
AC |
2 ms |
256 KB |
01-21.txt |
AC |
2 ms |
256 KB |
01-22.txt |
AC |
2 ms |
256 KB |
01-23.txt |
AC |
2 ms |
256 KB |
01-24.txt |
AC |
2 ms |
256 KB |
01-25.txt |
AC |
2 ms |
256 KB |
01-26.txt |
AC |
2 ms |
256 KB |
01-27.txt |
AC |
1 ms |
256 KB |
01-28.txt |
AC |
1 ms |
256 KB |
01-29.txt |
AC |
1 ms |
256 KB |
01-30.txt |
AC |
2 ms |
256 KB |
01-31.txt |
AC |
2 ms |
256 KB |
01-32.txt |
AC |
2 ms |
256 KB |
01-33.txt |
AC |
2 ms |
256 KB |
01-34.txt |
AC |
2 ms |
256 KB |
01-35.txt |
AC |
2 ms |
256 KB |
01-36.txt |
AC |
1 ms |
256 KB |
01-37.txt |
AC |
2 ms |
256 KB |
01-38.txt |
AC |
1 ms |
256 KB |
01-39.txt |
AC |
2 ms |
256 KB |
01-40.txt |
AC |
1 ms |
256 KB |
01-41.txt |
AC |
1 ms |
256 KB |
01-42.txt |
AC |
1 ms |
256 KB |
01-43.txt |
AC |
1 ms |
256 KB |
sample-01.txt |
AC |
1 ms |
256 KB |
sample-02.txt |
AC |
2 ms |
256 KB |
sample-03.txt |
AC |
1 ms |
256 KB |