HydroOJ - 信奥赛2023 PJ-A. 执理——题解
前言
注意注意:
- 本文🈲盗,转载请授权
- 本文原创
- OK ——》
—————————————————————————————————————————————————————————————————————
1970 - 进阶的卡莎
解法
#include<iostream>
using namespace std;
int line[1100], ans[10010];
// CSDN-熟int main(){int n, ith=0;cin >> n;for(int i=1; i<=n; i++) {cin >> line[i];}bool u=false;for (int i=2; i<=n; i++){if (line[i] > line[i-1]){ans[ith]++;u = false;}else {if(u == false){ith++;u = true;}}}int max=-1;for(int i=1; i<=ith; i++) {if(ans[i] > max) {max = ans[i];}}cout << max+1;return 0;
}
1971 - 合影效果
解法
#include<iostream>
#include<algorithm>
using namespace std;
char str[40];
double male[41], female[41], temp;
int cm=0, cf=0;
// CSND-熟int main() {int n;cin >> n;for (int i=1; i<=n; i++) {cin >> str >> temp;if (str[0] == 'f') {cf++;female[cf] = temp;}else {cm++;male[cm] = temp;}}for (int i=1; i<=cm; i++) {int idx=i;for (int j=i+1; j<=cm; j++) {if (male[j] < male[idx]) {idx = j;}}swap(male[idx],male[i]);}for(int i=1; i<=cf; i++){int idx=i;for(int j=i+1; j<=cf; j++) {if(female[j] > female[idx]) {idx = j;}}swap(female[idx], female[i]);}for (int i=1; i<=cm; i++) {printf("%.2lf ", male[i]);}for (int i=1; i<=cf; i++) {printf("%.2lf ", female[i]);}return 0;
}
完