1041 考试座位号
#include <iostream>
#include <map>
#include <string>
#include <utility>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
map<int, pair<string, int>> maps;
for (int i = 0; i != N; ++i) {
string a;
int b, c;
cin >> a >> b >> c;
maps[b] = {a, c};
}
cin >> N;
for (int i = 0; i != N; ++i) {
int b;
cin >> b;
cout << maps[b].first << " " << maps[b].second << endl;
}
return 0;
}
1042 字符统计
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(){
ios::sync_with_stdio(false);
map<char,int> counts;
int max = 0;
char maxchar = 'a' - 1;
char c;
while( (c = cin.get()) != '\n'){
if (!isalpha(c))
continue;
c = tolower(c);
++counts;
if (counts > max){
max = counts;
maxchar = c;
}else if (counts == max && c < maxchar){
maxchar = c;
}
}
cout << maxchar << " " << max << endl;
return 0;
}
1043 输出PATest
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
map<char, int> counts;
char c;
while ((c = cin.get()) != '\n') {
++counts;
}
vector<char> PATest = {'P', 'A', 'T', 'e', 's', 't'};
while (true) {
bool allempty = true;
for (int i = 0; i != 6; ++i)
if (counts[PATest[i]] > 0) {
cout << PATest[i];
--counts[PATest[i]];
allempty = false;
}
if (allempty)
break;
}
return 0;
}
1044 火星数字
// 13进制转换的题目啊
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
std::map<string, int> store = {
{"tret", 0}, {"jan", 1}, {"feb", 2}, {"mar", 3},
{"apr", 4}, {"may", 5}, {"jun", 6}, {"jly", 7},
{"aug", 8}, {"sep", 9}, {"oct", 10}, {"nov", 11},
{"dec", 12}, {"tam", 13 * 1}, {"hel", 13 * 2}, {"maa", 13 * 3},
{"huh", 13 * 4}, {"tou", 13 * 5}, {"kes", 13 * 6}, {"hei", 13 * 7},
{"elo", 13 * 8}, {"syy", 13 * 9}, {"lok", 13 * 10}, {"mer", 13 * 11},
{"jou", 13 * 12}};
vector<string> gewei = {"tret", "jan", "feb", "mar", "apr", "may", "jun",
"jly", "aug", "sep", "oct", "nov", "dec"};
vector<string> shiwei = {"", "tam", "hel", "maa", "huh", "tou", "kes",
"hei", "elo", "syy", "lok", "mer", "jou"};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
cin.get();
for (int i = 0; i != N; ++i) {
string input;
getline(cin, input);
if (isdigit(input[0])) { //说明这是个数字
int num = stoi(input);
if (num >= 13) {
cout << shiwei[num / 13] ;
num = num % 13;
if (num != 0)
cout << " " << gewei[num];
cout << endl;
}else{
cout << gewei[num] << endl;
}
} else {
int num = 0;
if (input.find(" ") != string::npos) { //有高位
string shi = input.substr(0, input.find(" "));
num += store[shi];
string ge = input.substr(input.find(" ") + 1, input.size());
num += store[ge];
} else {
num += store[input];
}
cout << num << endl;
}
}
return 0;
}
1045 快速排序
动态规划法
//想到动态规划。因为实际上你是在找这么一个值,什么值呢?左边的数字都比他小,右边的数字都比他大。
//这样想到的暴力方法是做循环,比如说你拿出第N个元素来,你把他左边的和他全部比一遍,右边的再比一遍
//这样重复的比较其实特别多,这些重复的子比较都可以纳入一个数组来管理,减少数组对比的时间
//因此考虑用一个max[i]表示从头到i元素的最大值,用一个min[i]表示从i元素到尾部的最小值。
//不包括i元素本身。
#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>
#define INT_MAX numeric_limits<int>::max()
using namespace std;
int main() {
ios::sync_with_stdio(false);
int N;
cin >> N;
vector<int> list(N, 0);
vector<int> min(N, INT_MAX);
vector<int> max(N, 0);
cin >> list[0];
if (N == 1) {
cout << 1 << endl;
cout << list[0] << endl;
return 0;
}
int lastnum = list[0];
for (int i = 1; i != N; ++i) {
int num;
cin >> num;
if (lastnum > max[i - 1])
max[i] = lastnum;
else
max[i] = max[i - 1];
lastnum = num;
list[i] = num;
}
max[0] = 0;
for (int i = N - 1; i > 0; --i) {
if (list[i] < min[i]) {
min[i - 1] = list[i];
} else
min[i - 1] = min[i];
}
min[N - 1] = INT_MAX;
vector<int> result;
for (int i = 0; i != N; ++i) {
if (max[i] < list[i] and min[i] > list[i]){
result.push_back(list[i]);
}
}
sort(result.begin(),result.end());
cout << result.size() << endl;
if(result.empty()){ //即使是空的,也必须输出一个空行,这坑是节点2,总之猝不及防。
cout << endl;
return 0;
}
for( int i = 0 ; i != result.size() - 1 ; ++i){
cout << result[i] << " ";
}
cout << result.back() << endl;
return 0;
}
暴力解法
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> input;
int k, num;
cin >> k;
while (k--) {
cin >> num;
input.push_back(num);
}
vector<int> result;
int max = input[0] - 1;
for (auto i : input) {
//因为保证输入中各数字互不相同,因此不存在i == max的情况
if (i > max) {
max = i;
result.push_back(max);
} else if (i < max) {
for (auto it = result.begin(); it != result.end(); ++it) {
if (*it > i)
it = result.erase(it);
if (it == result.end())
break;
}
}
}
if (result.size() == 0) {
cout << "0" << endl;
cout << endl;
return 0;
}
cout << result.size() << endl;
for (auto it = result.begin(); it != result.end() - 1; ++it)
cout << *it << " ";
cout << result.back();
return 0;
}
再提供一种解法
#include <iostream>
#include <vector>
//#include <fstream>
using namespace std;
int main() {
// ifstream in("in.txt");
// cin.rdbuf( in.rdbuf() );
size_t N;
cin >> N;
vector<int> Arr(N);
vector<int> Tmp(N, 0);
for (size_t i = 0; i != N; ++i) {
cin >> Arr[i];
}
int Max = Arr[0];
for (size_t i = 0; i != N; ++i) {
if (Max <= Arr[i]) {
Max = Arr[i];
++Tmp[i];
}
}
int Min = Arr[N - 1];
for (size_t i = N - 1; i != -1; --i) {
if (Min >= Arr[i]) {
Min = Arr[i];
++Tmp[i];
}
}
vector<int> Res;
for (size_t i = 0; i != N; ++i) {
if (2 == Tmp[i]) {
Res.push_back(Arr[i]);
}
}
cout << Res.size() << endl;
if (0 == Res.size()) {
cout << endl;
return 0;
}
for (size_t i = 0; i != Res.size(); ++i) {
if (i != Res.size() - 1)
cout << Res[i] << " ";
else
cout << Res[i] << endl;
}
return 0;
}
1046 划拳
#include<iostream>
#include<vector>
using namespace std;
int main(){
vector<int> drink(2,0);
int N;
cin >> N;
for(int i = 0 ; i != N ; ++i){
int jiahan,jiahua,yihan,yihua;
cin >> jiahan >> jiahua>>yihan>>yihua;
if (jiahua == yihua)
continue;
else if (jiahua == jiahan + yihan){
++drink[1];
}else if (yihua == jiahan + yihan){
++drink[0];
}
}
cout << drink[0] << " " <<drink[1] << endl;
return 0;
}
1047 编程团体赛
python
#就这都能用85ms
maxscore = 0
maxteam = -1
N = int(input())
total_score = dict()
for i in range(0,N):
team_player,score = input().split()
score = int(score)
team,player = team_player.split('-')
team = int(team)
if team in total_score:
total_score[team] += score
else:
total_score[team] = score;
if total_score[team] > maxscore:
maxscore = total_score[team]
maxteam = team
print(maxteam,maxscore)
cpp
//9ms
#include<string>
#include<iostream>
#include<map>
using namespace std;
int main() {
string input;
int k;
cin >> k;
std::getline(cin, input);
std::map<string, int> result;
string winner;
int max = 0, this_team;
while (k--) {
std::getline(cin, input);
this_team = (result[input.substr(0, input.find('-'))] += std::stoi(input.substr(input.find(' ') + 1)));
if (this_team > max) {
winner = input.substr(0, input.find('-'));
max = this_team;
}
}
cout << winner << " " << result[winner] << endl;
return 0;
}
1048 数字加密
#include<iostream>
#include<string>
//查了网上的分享才知道当A长度大于B时,B前面要补齐为0,所以怎么排BUG都排不出来……
//我认为这样的坑毫无意义,纯粹是题意不清。
using namespace std;
inline char process_jishu(char a, char b) {
int i = (a - '0' + b - '0') % 13;
if (i == 12)
return 'K';
else if (i == 11)
return 'Q';
else if (i == 10)
return 'J';
else return i + '0';
}
inline char process_oushu(char a, char b) {
int i = b - a;
return i < 0 ? i + 10 + '0' : i + '0';
}
int main() {
string A, B;
cin >> A >> B;
int i = 1;
if (A.size() > B.size())
B = string( A.size() - B.size(),'0') + B;
for (auto itB = B.rbegin(), itA = A.rbegin(); itB != B.rend() && itA != A.rend(); ++itB, ++itA) {
if (i % 2) {//奇数
*itB = process_jishu(*itA, *itB);
}
else {
*itB = process_oushu(*itA, *itB);
}
++i;
}
cout << B << endl;
return 0;
}
1049 数列的片段和
//这道题肯定是用乘法,考点在于每个数乘多少次
//稍微观察一下就能看出规律。
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int k;
double num;
cin >> k;
double result = 0.0;
for (int i = 0; i != k; ++i) {
cin >> num;
result += num * (i + 1) * (k - i);
}
cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) << result;
return 0;
}
1050 螺旋矩阵
//无他,但心细尔。
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int getm(int N) {
for (int i = sqrt(N); i <= N; ++i) {
if (N % i == 0)
return i;
}
}
int main() {
ios::sync_with_stdio(false);
int N;
cin >> N;
int m = getm(N);
int n = N / m;
if (m < n) {
int tmp = m;
m = n;
n = tmp;
}
vector<vector<int>> output(m, vector<int>(n, 0));
vector<int> input(N);
for (int i = 0; i != N; ++i) {
cin >> input[i];
}
sort(input.rbegin(), input.rend());
int row = 0;
int column = n - 1;
int row_up = m - 1;
int column_left = 0;
int idx = 0;
while (true) {
for (int j = column_left; j <= column; ++j) {
output[row][j] = input[idx++];
}
++row;
if (idx == N)
break;
for (int j = row; j <= row_up; ++j) {
output[j][column] = input[idx++];
}
--column;
if (idx == N)
break;
for (int j = column; j >= column_left; --j) {
output[row_up][j] = input[idx++];
}
--row_up;
if (idx == N)
break;
for (int j = row_up; j >= row; --j) {
output[j][column_left] = input[idx++];
}
++column_left;
if (idx == N)
break;
}
for (int i = 0; i != m; ++i) {
for (int j = 0; j != n - 1; ++j) {
cout << output[i][j] << " ";
}
cout << output[i].back() << endl;
}
return 0;
}
1051 复数乘法
//哎呦妈呀,要是这道题不能AC,不用怀疑,肯定是输出有问题。而不是计算有问题。
//这么复杂精细恶心的输出,简直别无分店呦。
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
class fushu {
friend std::ostream &operator<< (std::ostream &os, const fushu &a);
double shi = 0;
double xu = 0;
public:
fushu() {};
fushu(double a, double b) :shi(a), xu(b) {};
fushu(double a, double b, int c) {
shi = a * cos(b);
xu = a * sin(b);
};
fushu operator *(const fushu &a) {
fushu b; b.shi = shi * a.shi - xu * a.xu; b.xu = shi *a.xu + xu * a.shi; return b;
};
};
std::ostream &operator<< (std::ostream &os, const fushu &a) {
if (-0.005 < a.shi && a.shi< 0) {
cout << "0.00";
}
else {
cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) << a.shi;
}
if (a.xu >= 0) {
cout << "+" << std::setiosflags(std::ios::fixed) << std::setprecision(2) << a.xu << "i";
}
else if (-0.005 < a.xu && a.xu < 0) {
cout << "+0.00i";
}else {
cout << std::setiosflags(std::ios::fixed) << std::setprecision(2) << a.xu << "i";
}
return os;
}
int main() {
double R1, P1, R2, P2;
cin >> R1 >> P1 >> R2 >> P2;
fushu f1(R1, P1, 0), f2(R2, P2, 0);
cout << f1 * f2 << endl;
return 0;
}
1052 卖个萌
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string line;
vector<string> fuhao[3]; //分别是手足口
for (int i = 0; i != 3; ++i) {
getline(cin, line);
for (auto it = line.begin(); it != line.end();) {
string tmp;
if (*it == '[') {
++it;
while (*it != ']') {
tmp += *it;
++it;
}
fuhao[i].push_back(tmp);
} else {
++it;
}
}
}
int N;
cin >> N;
string output;
for (int i = 0; i != N; ++i) {
for (int j = 0; j != 5; ++j) {
int index = j > 2 ? 4 - j : j;
int tmp;
cin >> tmp;
if (tmp > fuhao[index].size() || tmp < 1) {
output.clear();
output = "Are you kidding me? @\\/@";
break;
} else {
output +=
(j == 1 ? "(" : "") + fuhao[index][tmp - 1] + (j == 3 ? ")" : "");
}
}
cout << output << endl;
output.clear();
}
return 0;
}
1053 住房空置率
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int house_num, date_num;
float e;
cin >> house_num >> e >> date_num;
int maybe_empty = 0, empty = 0;
for (int i = 0; i != house_num; ++i) {
int K, low_day_num = 0;
cin >> K;
for (int j = 0; j != K; ++j) {
float tmp;
cin >> tmp;
if (tmp < e) {
++low_day_num;
}
}
if (low_day_num > K / 2) {
if (K > date_num)
++empty;
else
++maybe_empty;
}
}
cout.flags(ios::fixed);
cout.precision(1);
cout << maybe_empty * 100 / 1.0 / house_num << "% " << empty * 100 / 1.0 / house_num << "%" << endl;
}
1054 求平均值
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool islegal(const string &a) {
int dotnum = 0;
int digit_after_dot_num = 0;
bool digit = false;
for (int i = 0; i != a.size(); ++i) {
if (!isdigit(a[i]) && a[i] != '+' && a[i] != '-' && a[i] != '.') {
return false;
} else {
if (isdigit(a[i])) {
digit = true;
if (dotnum != 0) {
++digit_after_dot_num;
if (digit_after_dot_num > 2)
return false;
}
} else if (digit && (a[i] == '+' || a[i] == '-')) {
return false;
} else if (a[i] == '.') {
++dotnum;
if (dotnum > 1)
return false;
}
}
}
//到这里至少看起来是个合法的数字了。
if (stof(a) > 1000 || stof(a) < -1000)
return false;
else return true;
}
int main(){
ios::sync_with_stdio(false);
int N;
cin >> N;
string inp;
float total = 0.0;
int legalnum = 0;
vector<string> illegal;
for(int i = 0 ; i != N ; ++i){
cin >> inp;
if (islegal(inp)){
total += stof(inp);
++legalnum;
}else{
illegal.push_back(inp);
}
}
for(auto it = illegal.begin() ; it != illegal.end() ; ++it){
cout << "ERROR: " << *it <<" is not a legal number" << endl;
}
if (legalnum != 0){
cout.flags(ios::fixed);
cout.precision(2);
cout << "The average of " << legalnum
<< (legalnum > 1 ? " numbers" : " number") << " is "
<< total / legalnum << endl;
}else{
cout << "The average of 0 numbers is Undefined" << endl;
}
return 0;
}
1055 集体照
//这道理理解起来最大的歧义在于,什么叫人身高相同,按名字的字典升序排列。
//这牵扯两个方面,一是身高相同的恰好在一列,那简单,按照升序排列就行了。
//关键是身高相同的如果不在同一列怎么办。到底是名字小的在前一排还是名字大的在前一排?
//答案会告诉你,实际上是名字大的在前一排。
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct Person {
int height;
string name;
};
int main() {
ios::sync_with_stdio(false);
int studentnum, linenum;
cin >> studentnum >> linenum;
vector<Person> students(studentnum);
for (int i = 0; i != studentnum; ++i) {
cin >> students[i].name >> students[i].height;
}
sort(students.begin(), students.end(), [](const Person &a, const Person &b) {
return a.height < b.height || (a.height == b.height && a.name > b.name);
}); //名字大的在前一排
int persons_per_line = studentnum / linenum;
vector<vector<string>> ordered;
int lastindex = 0;
for (int i = 0; i != linenum; ++i) {
if (i == linenum - 1)
persons_per_line = studentnum - (linenum - 1) * persons_per_line;
vector<string> perline(persons_per_line);
int pos = persons_per_line / 2; //不加1是因为从零开始
int pianyi = -1;
sort(students.begin() + lastindex,
students.begin() + lastindex + persons_per_line,
[](const Person &a, const Person &b) {
return a.height > b.height ||
(a.height == b.height && a.name < b.name);
});
//这里是名字小的靠前
for (int j = lastindex; j != lastindex + persons_per_line; ++j) {
perline[pos] = students[j].name;
pos += pianyi;
pianyi = pianyi > 0 ? (pianyi + 1) * -1 : (pianyi - 1) * -1;
}
ordered.push_back(perline);
lastindex += persons_per_line;
}
for (auto it = ordered.rbegin(); it != ordered.rend(); ++it) {
for (auto it2 = it->begin(); it2 != it->end() - 1; ++it2) {
cout << *it2 << " ";
}
cout << it->back() << endl;
}
return 0;
}
1056 组合数的和
#include<iostream>
using namespace std;
int main(){
int N;
cin >> N;
int sum = 0;
for(int i = 0 ; i != N ; ++i){
int tmp;
cin >> tmp;
sum += tmp;
}
cout << sum * (N -1) * 11 << endl;
return 0;
}
1057 数零壹
#include <iostream>
#include <string>
using namespace std;
int main() {
string line;
getline(cin, line);
int sum = 0;
for (int i = 0; i != line.size(); ++i) {
if (isalpha(line[i])) {
sum += tolower(line[i]) - 'a' + 1;
}
}
int num[] = {0, 0};
while (sum != 0) {
int r = sum % 2;
sum /= 2;
++num[r];
}
cout << num[0] << " " << num[1] << endl;
return 0;
}
1058 选择题
//这道题算是1073的简化版吗?
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <fstream>
using namespace std;
#define RIGHT 0
#define WRONG 1
struct Timu {
int score; //分值
int xx_num; //选项数量
int r_xx_num; //正确选项数量
vector<char> xxs;
};
void parasline(const string &line, const int timunum,
vector<vector<char>> &res) {
istringstream is(line);
char kuohao;
for (int i = 0; i != timunum; ++i) {
int num = 0;
is >> kuohao;
is >> num;
for (int j = 0; j != num; ++j) {
char c;
is >> c;
res[i].push_back(c);
}
sort(res[i].begin(),res[i].end());
is >> kuohao;
}
}
int pigai(const vector<vector<char>> &choose, const vector<Timu> &timus,
const int timunum, map<int, int> &wrongs, int &mostwrong) {
int res = 0;
for (int i = 0; i != timunum; ++i) {
int status = RIGHT;
if (choose[i] == timus[i].xxs) {
res += timus[i].score;
} else {
++wrongs[i];
if (wrongs[i] > mostwrong)
mostwrong = wrongs[i];
}
}
return res;
}
int main() {
int student_num, timunum;
cin >> student_num >> timunum;
vector<Timu> timus(timunum);
for (int i = 0; i != timunum; ++i) {
cin >> timus[i].score >> timus[i].xx_num >> timus[i].r_xx_num;
for (int j = 0; j != timus[i].r_xx_num; ++j) {
char c;
cin >> c;
timus[i].xxs.push_back(c);
}
sort(timus[i].xxs.begin(),timus[i].xxs.end());
}
map<int, int> wrongs; // key是题目序号和错误选项,int是错误次数
cin.get();
int mostwrong = 0;
vector<int> students(student_num, 0.0);
for (int i = 0; i != student_num; ++i) {
string line;
getline(cin, line);
vector<vector<char>> choose(timunum);
parasline(line, timunum, choose);
students[i] += pigai(choose, timus, timunum, wrongs, mostwrong);
}
for (auto it = students.begin(); it != students.end(); ++it) {
cout << *it << endl;
}
if (wrongs.empty()) {
cout << "Too simple" << endl;
return 0;
}
cout << mostwrong;
for (auto it = wrongs.begin(); it != wrongs.end(); ++it) {
if (it->second == mostwrong) {
cout << " " << it->first + 1;
}
}
return 0;
}
1059 C语言竞赛
#include <cstdio>
#include <map>
#include <math.h>
#include <vector>
using namespace std;
bool issu(int a) {
if (a == 2 || a == 3)
return true;
else if (a % 2 == 0)
return false;
for (int i = 3; i <= sqrt(a) + 1; i += 2) {
if (a % i == 0)
return false;
}
return true;
}
int main() {
int compnents, query;
scanf("%d", &compnents);
map<int, int> reward;
for (int i = 0; i != compnents; ++i) {
int index;
scanf("%d", &index);
if (i == 0) {
reward[index] = 1;
} else if (issu(i + 1)) {
reward[index] = 2;
} else {
reward[index] = 3;
}
}
scanf("%d", &query);
for (int i = 0; i != query; ++i) {
int n;
scanf("%d", &n);
switch (reward[n]) {
case 0:
printf("%04d: Are you kidding?\n", n);
break;
case 1:
printf("%04d: Mystery Award\n", n);
reward[n] = 4;
break;
case 2:
printf("%04d: Minion\n", n);
reward[n] = 4;
break;
case 3:
printf("%04d: Chocolate\n", n);
reward[n] = 4;
break;
case 4:
printf("%04d: Checked\n", n);
break;
}
}
return 0;
}
1060 爱丁顿数
//先考虑暴力解法,我先把任何一公里的天数求出来,比如A[i]表示超过i公里的天数
//之后再去遍历这个数组,找i和A[i]这个值对中最小值的最大值。
//但是问题在于,每次有一个大数出现后,就要更新之前全部的数组,这更新下来压力很大。
//该怎么办呢。所以肯定不行。考虑用一个数组保存每天跑了几公里。然后从大到小排个序
//之后从头开始数,如果公里数大于天数(天数从1开始,所以是index+1),那就继续往下数
//这就相当于数超过某公里的天数。结果当公里数不能大于天数了,就不能继续下去了。
//比如提供这么一个序列
//10
//6 6 6 9 3 10 8 2 7 8
//排序后得到[10, 9, 8, 8, 7, 6, 6, 6, 3, 2]从头往后数
//问题关键在于能不能数第一个6,也就是说当gongli[i] == i + 1的时候该怎么处理
//这么显然是不能继续往下数,因为题目要求是超过E公里,而不是等于E公里了。
#include <algorithm>
#include <cstdio>
#include <map>
#include <vector>
using namespace std;
int main() {
// freopen("input","r",stdin);
int days;
scanf("%d", &days);
vector<int> gongli(days, 0);
int E = 0;
for (int i = 0; i != days; ++i) {
scanf("%d", &gongli[i]);
}
sort(gongli.rbegin(), gongli.rend());
for (int i = 0; i != gongli.size(); ++i) {
if (gongli[i] > i + 1)
++E;
else break;
}
printf("%d\n", E);
return 0;
}
0 条评论