QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372790#4398. Luxury cruise shipYcfhnndTL 0ms0kbC++20771b2024-03-31 19:16:012024-03-31 19:16:03

Judging History

你现在查看的是最新测评结果

  • [2024-03-31 19:16:03]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-03-31 19:16:01]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;
map<i64, i64>mp;

i64 get(i64 x){
    if (mp.count(x)) return mp[x];
    if (x < 7) mp[x] = 1e16;
    i64 a = 1e16;
    i64 b = 1e16;
    i64 c = 1e16;
    if (x >= 365) a = get(x - 365);
    if (x >= 31) b = get(x - 31);
    if (x >= 7) c = get(x - 7);
    mp[x] = min({a, b, c}) + 1;
    return mp[x];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    mp[7] = 1, mp[31] = 1, mp[365] = 1;
    mp[0] = 0;
    for (int i = 0;i < n;i ++){
        i64 x;
        cin >> x;
        if (get(x) >= 1e16){
            cout << "-1\n";
        }else{
            cout << get(x) << "\n";
        }
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

1000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101...

output:


result: