Precreation contest files
This commit is contained in:
BIN
misc/bdhsg_1015/a.out
Executable file
BIN
misc/bdhsg_1015/a.out
Executable file
Binary file not shown.
21
misc/bdhsg_1015/max3.cpp
Normal file
21
misc/bdhsg_1015/max3.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
ios_base::sync_with_stdio(false);
|
||||
cin.tie(NULL);
|
||||
freopen("max3.inp", "r", stdin);
|
||||
|
||||
int n;
|
||||
cin >> n;
|
||||
vector<int> a(n);
|
||||
for (int &i : a)
|
||||
cin >> i;
|
||||
|
||||
int res = 0;
|
||||
for (int i = 0; i < n - 2; i++)
|
||||
res = max(res, a[i] + a[i + 1] + a[i + 2]);
|
||||
|
||||
cout << res << '\n';
|
||||
}
|
||||
2
misc/bdhsg_1015/max3.inp
Normal file
2
misc/bdhsg_1015/max3.inp
Normal file
@@ -0,0 +1,2 @@
|
||||
6
|
||||
1 3 4 2 7 9
|
||||
32
misc/bdhsg_1015/search.cpp
Normal file
32
misc/bdhsg_1015/search.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
ios_base::sync_with_stdio(false);
|
||||
cin.tie(NULL);
|
||||
freopen("search.inp", "r", stdin);
|
||||
|
||||
int n, x;
|
||||
cin >> n >> x;
|
||||
vector<int> a(n);
|
||||
for (int &i : a)
|
||||
cin >> i;
|
||||
|
||||
if (x - 1 > n || x < 0) {
|
||||
cout << -1 << '\n';
|
||||
return 0;
|
||||
} else {
|
||||
x = a[x - 1];
|
||||
}
|
||||
int cnt = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
// cout << a[i] << '\n';
|
||||
if (a[i] == x) {
|
||||
cout << i + 1 << ' ';
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
cout << '\n';
|
||||
cout << ((cnt == 0) ? -1 : cnt) << '\n';
|
||||
}
|
||||
2
misc/bdhsg_1015/search.inp
Normal file
2
misc/bdhsg_1015/search.inp
Normal file
@@ -0,0 +1,2 @@
|
||||
6 2
|
||||
1 3 3 5 7 3
|
||||
0
misc/bdhsg_1015/search2.cpp
Normal file
0
misc/bdhsg_1015/search2.cpp
Normal file
0
misc/bdhsg_1015/search2.inp
Normal file
0
misc/bdhsg_1015/search2.inp
Normal file
Reference in New Issue
Block a user