2023 ICPC(亚)预选赛9.17第一场 题解

只做出A、L就只写这两吧(雾

A

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
#include<bits/stdc++.h>

using namespace std;

const int N = 100100;

long long n,m;
string s1[N],s2[N];

map<string, bool> ex; // exist
map<long long, string> st; // store

map<string, bool> e1; // exist for s1
map<string, bool> e2; // exist for s2

vector<string> ans; //answer

int main()
{
cin >> n >>m;

for (int i = 0; i < n; ++ i){
cin >> s1[i];
}

for (int i = 0; i < m; ++ i){
cin >> s2[i];
}//get

int max_n = max(n, m);

long long idx = 0;
long long p1 = 0, p2 = 0;

for (int i = 0; i + p1 < n || i + p2 < m; i ++){
while (e1[s1[i + p1]] == 1 ){
p1 ++;
if (i + p1 >= n ){
break;
}
}
if (i + p1 < n ){
st[idx ++] = s1[i + p1];
e1[s1[i + p1]] = 1;
}

while (e2[s2[i + p2]] == 1 ){
p2 ++;
if (i + p2 >= m){
break;
}
}

if (i + p2 < m){
st[idx ++] = s2[i + p2];
e2[s2[i + p2]] = 1;
}
}

/*
if (n > m){
for (int i = m; i < n; i ++){
st[idx++] = s1[i];
}
}
if (m > n){
for (int i = n; i < m; i ++){
st[idx++] = s2[i];
}
}
*/

for (long long i = 0; i < idx; i ++){
if (ex[st[i]] != 1){
ans.push_back(st[i]);
ex[st[i]] = 1;
}
}

for (long long i = 0; i < ans.size() - 1; i++){
cout << ans[i] << endl;
}
cout << ans[ans.size() - 1];

}

L

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
#include<bits/stdc++.h>
using namespace std;

int main(){
int n,t;
cin >> n >> t;

int ans = 0;

long long maxt = -1;

for (int i = 0; i < n; i++){
long long x;
cin >> x;

maxt = max (x, maxt);
}

ans = maxt / t;

if (maxt % t != 0)
ans ++;

if (ans >= 2)
printf("%d\n",ans);
else
cout << 2 << endl;

}