Submission #8927018
Source Code Expand
#include "bits/stdc++.h" using namespace std; using lint = long long; #define low lower_bound #define upp upper_bound #define rep(i, n) for (lint i = 0; i < lint(n); ++i) #define Rep(i, n) for (lint i = lint(n); i >= 0; --i) #define all(vec) (vec).begin(), (vec).end() #define cend printf("\n"); #define prique(T) priority_queue<T, vector<T>, greater<T>> #define prique2(T) priority_queue<T> struct edge { int to; double cost; }; using P = pair<lint, lint>; using D = pair<double, double>; using DI = pair<double, int>; //const lint mod = 998244353LL; const lint mod = 1000000007LL; const lint inf = 3LL * mod * mod; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } lint modpow(lint x, lint n, lint m) { lint ans = 1; while (n > 0) { if (n & 1) { ans *= x; if (m <= ans) ans %= m; } x *= x; if (m <= x) x %= m; n >>= 1; } return ans; } lint fact[1000000]; void f_init(lint n) { if (1000000 <= n) return; fact[0] = fact[1] = 1; for (lint i = 2; i <= n; ++i) { fact[i] = i * fact[i - 1]; if (mod <= fact[i]) fact[i] %= mod; } return; } lint inver[1000000]; bool inve[100000]; lint inv(lint x) { if (x == 0) return 0; else if (inve[x]) return inver[x]; else { inve[x] = true; return inver[x] = modpow(x, mod - 2, mod); } } lint comb(lint n, lint r) { if (n < r) return 0; if (n == r) return 1; lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod; if (ans < 0) return ans + mod; return ans; } lint nck[1010][1010]; void comb(lint n) { rep(i, n + 1) { rep(j, i + 1) { if (j == 0 || i == j) nck[i][j] = 1; else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j]; } } } lint gcd(lint a, lint b) { if (b == 0) return a; return gcd(b, a % b); } lint lcm(lint a, lint b) { return a / gcd(a, b) * b; } bool pri(lint p) { for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false; return p > 1; } map<lint, lint> factring(lint n) { map<lint, lint>ans; for (lint i = 2; i * i <= n; ++i) { while (n % i == 0) { n /= i; ++ans[i]; } } if (n != 1) ++ans[n]; return ans; } double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); } int n, d[55], ans = 24; int main() { cin >> n; rep(i, n) { cin >> d[i + 1]; } sort(d, d + n + 1); for (int i = 0; i < n + 1; i += 2) { d[i] = 24 - d[i]; } rep(i, n + 1) { for (int j = i + 1; j < n + 1; ++j) { ans = min(ans, min(abs(d[i] - d[j]), 24 - abs(d[i] - d[j]))); } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Time Gap |
User | Ebishu0309 |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 2817 Byte |
Status | AC |
Exec Time | 1 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 | 1 ms | 256 KB |
01-09.txt | AC | 1 ms | 256 KB |
01-10.txt | AC | 1 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 | 1 ms | 256 KB |
01-18.txt | AC | 1 ms | 256 KB |
01-19.txt | AC | 1 ms | 256 KB |
01-20.txt | AC | 1 ms | 256 KB |
01-21.txt | AC | 1 ms | 256 KB |
01-22.txt | AC | 1 ms | 256 KB |
01-23.txt | AC | 1 ms | 256 KB |
01-24.txt | AC | 1 ms | 256 KB |
01-25.txt | AC | 1 ms | 256 KB |
01-26.txt | AC | 1 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 | 1 ms | 256 KB |
01-31.txt | AC | 1 ms | 256 KB |
01-32.txt | AC | 1 ms | 256 KB |
01-33.txt | AC | 1 ms | 256 KB |
01-34.txt | AC | 1 ms | 256 KB |
01-35.txt | AC | 1 ms | 256 KB |
01-36.txt | AC | 1 ms | 256 KB |
01-37.txt | AC | 1 ms | 256 KB |
01-38.txt | AC | 1 ms | 256 KB |
01-39.txt | AC | 1 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 | 1 ms | 256 KB |
sample-03.txt | AC | 1 ms | 256 KB |