黄海 1 year ago
commit 8022acfd97

@ -1,48 +1,9 @@
#include <bits/stdc++.h> #include <bits/stdc++.h>
using namespace std; using namespace std;
const int INF = 0x3f3f3f3f; #define endl '\n'
const int N = 110;
double a[N];
int n;
int f1[N], f2[N];
int main() { int main() {
cin >> n; // 加快读入
for (int i = 1; i <= n; i++) cin >> a[i]; ios::sync_with_stdio(false), cin.tie(0);
for (int i = 1; i <= n; i++) { cout << "dd" << endl;
f1[i] = 1;
for (int j = 1; j < i; j++)
if (a[i] > a[j]) f1[i] = max(f1[i], f1[j] + 1);
}
for (int i = n; i >= 1; i--) {
f2[i] = 1;
for (int j = 1; j < i; j++)
if (a[i] > a[j]) f2[i] = max(f1[i], f1[j] + 1);
}
bool flag = true;
for (int i = 1; i <= n; i++)
if (f1[i] != 1) {
flag = false;
break;
}
if (flag) {
cout << -1 << endl;
exit(0);
}
flag = true;
for (int i = 1; i <= n; i++)
if (f2[i] != 1) {
flag = false;
break;
}
if (flag) {
cout << -1 << endl;
exit(0);
}
int mx = -1;
for (int i = 1; i <= n; i++){
int t = f1[i] + f2[i];
mx = max(mx, t);
}
cout << n - mx + 1;
return 0; return 0;
} }

@ -1,16 +1,9 @@
#include <bits/stdc++.h> #include <bits/stdc++.h>
using namespace std; using namespace std;
int n; #define endl '\n'
const int N = 110;
typedef long long LL;
LL a[N];
LL res;
int main() { int main() {
while (cin >> a[++n]); // 加快读入
n--; ios::sync_with_stdio(false), cin.tie(0);
for (int i = 1; i <= n; i++)res += a[i] * pow(2, n - 1); cout << "aaa" << endl;
printf("%d", res);
return 0; return 0;
} }

@ -1,25 +1,25 @@
{ {
"configurations": [ "configurations": [
{ {
"name": "Win32", "name": "Win32",
"compilerArgs": [ "compilerArgs": [
"-fexec-charset=GBK" "-fexec-charset=GBK"
], ],
"includePath": [ "includePath": [
"${workspaceFolder}/**", "${workspaceFolder}/**",
"C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/10.3.0/**", "C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/10.3.0/**",
"C:/TDM-GCC-64/x86_64-w64-mingw32/include/**" "C:/TDM-GCC-64/x86_64-w64-mingw32/include/**"
], ],
"defines": [ "defines": [
"_DEBUG", "_DEBUG",
"UNICODE", "UNICODE",
"_UNICODE" "_UNICODE"
], ],
"compilerPath": "C:/TDM-GCC-64/bin/gcc.exe", "compilerPath": "C:/TDM-GCC-64/bin/gcc.exe",
"cStandard": "c11", "cStandard": "c11",
"cppStandard": "c++17", "cppStandard": "c++17",
"intelliSenseMode": "gcc-x64" "intelliSenseMode": "gcc-x64"
} }
], ],
"version": 4 "version": 4
} }
Loading…
Cancel
Save