QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#73432 | #5279. New Time | sinbad | AC ✓ | 3ms | 3552kb | C++ | 4.2kb | 2023-01-25 13:01:59 | 2023-01-25 13:02:00 |
Judging History
answer
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const multiset<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
template <class T> auto vect(const T& v, int n) { return vector<T>(n, v); }
template <class T, class... D> auto vect(const T& v, int n, D... m) {
return vector<decltype(vect(v, m...))>(n, vect(v, m...));
}
using int64 = long long;
using int128 = __int128_t;
using ii = pair<int, int>;
#define SZ(x) (int)((x).size())
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
mt19937_64 mrand(random_device{}());
int64 rnd(int64 x) { return mrand() % x; }
constexpr inline int lg2(int64 x) { return x == 0 ? -1 : sizeof(int64) * 8 - 1 - __builtin_clzll(x); }
constexpr inline int p2ceil(int64 x) { return 1 << (lg2(x - 1) + 1); }
template <class T> void out(const vector<T>& a) { for (int i = 0; i < SZ(a); ++i) cout << a[i] << " \n"[i + 1 == SZ(a)]; }
template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template <class T> void dedup(vector<T>& v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); }
inline void add_mod(int& x, int y) { x += y; if (x >= MOD) x -= MOD; }
inline void sub_mod(int& x, int y) { x += MOD - y; if (x >= MOD) x -= MOD; }
inline int mod(int x) { return x >= MOD ? x - MOD : x; }
struct fast_ios {
fast_ios() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
};
} fast_ios_;
int main() {
int h1, m1, h2, m2;
scanf("%d:%d", &h1, &m1);
scanf("%d:%d", &h2, &m2);
int ret = inf<int>;
for (int k = 0; k < 24; ++k) {
int cur = k >= h1 ? k - h1 : k - h1 + 24;
int x = k * 60 + m1, y = h2 * 60 + m2;
// trace(k, x, y, cur);
if (y >= x) {
cur += y - x;
} else {
cur += y - x + 24 * 60;
}
ckmin(ret, cur);
}
cout << ret << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3516kb
input:
11:57 12:00
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
09:09 21:21
output:
24
result:
ok 1 number(s): "24"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3392kb
input:
19:44 08:50
output:
19
result:
ok 1 number(s): "19"
Test #4:
score: 0
Accepted
time: 2ms
memory: 3392kb
input:
13:45 17:58
output:
17
result:
ok 1 number(s): "17"
Test #5:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
02:57 21:05
output:
26
result:
ok 1 number(s): "26"
Test #6:
score: 0
Accepted
time: 2ms
memory: 3392kb
input:
18:15 22:59
output:
48
result:
ok 1 number(s): "48"
Test #7:
score: 0
Accepted
time: 2ms
memory: 3416kb
input:
18:12 09:42
output:
45
result:
ok 1 number(s): "45"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
00:00 00:00
output:
0
result:
ok 1 number(s): "0"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
00:00 23:59
output:
82
result:
ok 1 number(s): "82"
Test #10:
score: 0
Accepted
time: 2ms
memory: 3416kb
input:
23:59 00:00
output:
1
result:
ok 1 number(s): "1"
Test #11:
score: 0
Accepted
time: 1ms
memory: 3552kb
input:
23:59 23:59
output:
0
result:
ok 1 number(s): "0"
Test #12:
score: 0
Accepted
time: 2ms
memory: 3384kb
input:
18:55 18:55
output:
0
result:
ok 1 number(s): "0"
Test #13:
score: 0
Accepted
time: 2ms
memory: 3412kb
input:
18:54 18:55
output:
1
result:
ok 1 number(s): "1"
Test #14:
score: 0
Accepted
time: 2ms
memory: 3472kb
input:
18:56 18:55
output:
82
result:
ok 1 number(s): "82"
Test #15:
score: 0
Accepted
time: 2ms
memory: 3392kb
input:
18:59 19:00
output:
1
result:
ok 1 number(s): "1"
Test #16:
score: 0
Accepted
time: 2ms
memory: 3540kb
input:
09:00 08:59
output:
82
result:
ok 1 number(s): "82"
Test #17:
score: 0
Accepted
time: 2ms
memory: 3480kb
input:
01:43 22:26
output:
63
result:
ok 1 number(s): "63"
Test #18:
score: 0
Accepted
time: 2ms
memory: 3504kb
input:
17:23 23:04
output:
46
result:
ok 1 number(s): "46"
Test #19:
score: 0
Accepted
time: 2ms
memory: 3440kb
input:
01:47 17:42
output:
70
result:
ok 1 number(s): "70"
Test #20:
score: 0
Accepted
time: 2ms
memory: 3440kb
input:
09:56 19:55
output:
68
result:
ok 1 number(s): "68"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
17:36 20:33
output:
59
result:
ok 1 number(s): "59"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
09:09 22:55
output:
59
result:
ok 1 number(s): "59"
Test #23:
score: 0
Accepted
time: 2ms
memory: 3436kb
input:
17:49 16:32
output:
65
result:
ok 1 number(s): "65"
Test #24:
score: 0
Accepted
time: 2ms
memory: 3504kb
input:
01:13 09:10
output:
64
result:
ok 1 number(s): "64"
Test #25:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
17:22 11:23
output:
19
result:
ok 1 number(s): "19"
Test #26:
score: 0
Accepted
time: 3ms
memory: 3520kb
input:
23:56 11:17
output:
32
result:
ok 1 number(s): "32"
Test #27:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
07:20 04:38
output:
39
result:
ok 1 number(s): "39"
Test #28:
score: 0
Accepted
time: 2ms
memory: 3384kb
input:
23:01 14:16
output:
30
result:
ok 1 number(s): "30"
Test #29:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
23:25 16:38
output:
30
result:
ok 1 number(s): "30"
Test #30:
score: 0
Accepted
time: 2ms
memory: 3432kb
input:
15:58 09:31
output:
50
result:
ok 1 number(s): "50"
Test #31:
score: 0
Accepted
time: 2ms
memory: 3380kb
input:
07:22 19:45
output:
35
result:
ok 1 number(s): "35"
Test #32:
score: 0
Accepted
time: 2ms
memory: 3492kb
input:
07:46 20:23
output:
49
result:
ok 1 number(s): "49"
Test #33:
score: 0
Accepted
time: 2ms
memory: 3416kb
input:
00:11 22:44
output:
55
result:
ok 1 number(s): "55"
Test #34:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
08:51 16:22
output:
38
result:
ok 1 number(s): "38"
Test #35:
score: 0
Accepted
time: 2ms
memory: 3380kb
input:
00:23 01:51
output:
29
result:
ok 1 number(s): "29"
Test #36:
score: 0
Accepted
time: 0ms
memory: 3380kb
input:
02:22 21:05
output:
61
result:
ok 1 number(s): "61"
Test #37:
score: 0
Accepted
time: 0ms
memory: 3380kb
input:
00:19 00:19
output:
0
result:
ok 1 number(s): "0"
Test #38:
score: 0
Accepted
time: 2ms
memory: 3436kb
input:
23:47 23:48
output:
1
result:
ok 1 number(s): "1"
Test #39:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
07:47 07:49
output:
2
result:
ok 1 number(s): "2"
Test #40:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
10:59 11:03
output:
4
result:
ok 1 number(s): "4"
Test #41:
score: 0
Accepted
time: 2ms
memory: 3476kb
input:
17:23 17:31
output:
8
result:
ok 1 number(s): "8"
Test #42:
score: 0
Accepted
time: 2ms
memory: 3420kb
input:
16:31 16:47
output:
16
result:
ok 1 number(s): "16"
Test #43:
score: 0
Accepted
time: 2ms
memory: 3544kb
input:
14:34 14:58
output:
24
result:
ok 1 number(s): "24"
Test #44:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
22:34 23:33
output:
59
result:
ok 1 number(s): "59"
Test #45:
score: 0
Accepted
time: 2ms
memory: 3472kb
input:
21:09 22:09
output:
1
result:
ok 1 number(s): "1"
Test #46:
score: 0
Accepted
time: 2ms
memory: 3420kb
input:
05:09 06:10
output:
2
result:
ok 1 number(s): "2"
Test #47:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
19:33 21:08
output:
36
result:
ok 1 number(s): "36"
Test #48:
score: 0
Accepted
time: 2ms
memory: 3524kb
input:
18:07 20:06
output:
60
result:
ok 1 number(s): "60"
Test #49:
score: 0
Accepted
time: 2ms
memory: 3524kb
input:
18:17 20:17
output:
2
result:
ok 1 number(s): "2"
Test #50:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
02:17 04:18
output:
3
result:
ok 1 number(s): "3"
Test #51:
score: 0
Accepted
time: 0ms
memory: 3408kb
input:
14:03 18:05
output:
6
result:
ok 1 number(s): "6"
Test #52:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
04:20 11:19
output:
65
result:
ok 1 number(s): "65"
Test #53:
score: 0
Accepted
time: 2ms
memory: 3508kb
input:
08:46 15:46
output:
7
result:
ok 1 number(s): "7"
Test #54:
score: 0
Accepted
time: 1ms
memory: 3504kb
input:
17:34 05:23
output:
60
result:
ok 1 number(s): "60"
Test #55:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
12:57 00:56
output:
70
result:
ok 1 number(s): "70"
Test #56:
score: 0
Accepted
time: 2ms
memory: 3476kb
input:
17:23 05:23
output:
12
result:
ok 1 number(s): "12"
Test #57:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
16:51 04:52
output:
13
result:
ok 1 number(s): "13"
Test #58:
score: 0
Accepted
time: 2ms
memory: 3416kb
input:
22:22 10:33
output:
23
result:
ok 1 number(s): "23"
Test #59:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
04:40 21:40
output:
17
result:
ok 1 number(s): "17"
Test #60:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
04:08 21:09
output:
18
result:
ok 1 number(s): "18"
Test #61:
score: 0
Accepted
time: 2ms
memory: 3416kb
input:
14:40 10:38
output:
77
result:
ok 1 number(s): "77"
Test #62:
score: 0
Accepted
time: 2ms
memory: 3392kb
input:
14:43 12:42
output:
80
result:
ok 1 number(s): "80"
Test #63:
score: 0
Accepted
time: 1ms
memory: 3536kb
input:
19:09 17:09
output:
22
result:
ok 1 number(s): "22"
Test #64:
score: 0
Accepted
time: 2ms
memory: 3544kb
input:
18:37 16:38
output:
23
result:
ok 1 number(s): "23"
Test #65:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
01:55 00:20
output:
47
result:
ok 1 number(s): "47"
Test #66:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
20:35 19:34
output:
81
result:
ok 1 number(s): "81"
Test #67:
score: 0
Accepted
time: 2ms
memory: 3508kb
input:
19:10 18:10
output:
23
result:
ok 1 number(s): "23"
Test #68:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
18:38 17:39
output:
24
result:
ok 1 number(s): "24"
Test #69:
score: 0
Accepted
time: 3ms
memory: 3508kb
input:
19:11 18:47
output:
59
result:
ok 1 number(s): "59"
Test #70:
score: 0
Accepted
time: 2ms
memory: 3472kb
input:
12:57 12:41
output:
67
result:
ok 1 number(s): "67"
Test #71:
score: 0
Accepted
time: 2ms
memory: 3516kb
input:
11:00 10:52
output:
75
result:
ok 1 number(s): "75"
Test #72:
score: 0
Accepted
time: 2ms
memory: 3440kb
input:
21:40 21:36
output:
79
result:
ok 1 number(s): "79"
Test #73:
score: 0
Accepted
time: 2ms
memory: 3544kb
input:
05:08 05:06
output:
81
result:
ok 1 number(s): "81"
Test #74:
score: 0
Accepted
time: 2ms
memory: 3476kb
input:
04:36 04:35
output:
82
result:
ok 1 number(s): "82"