文章
99
粉丝
120
获赞
8
访问
97.5k
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct ant {
int pos;
int direct;
};
bool compare(ant a1, ant a2) {
return a1.pos < a2.pos;
}
int main() {
ant arr[100];
int n;
cin >> n;
int des, way;
int current;
for (int i = 0; i < n; i++) {
cin >> des >> way;
arr[i].pos = des;
arr[i].direct = way;
if (way == 0)
current = des;
}
sort(arr, arr + n, compare);
vector<ant>left, right;
for (int i = 0; i < n; i++) {
if (arr[i].direct == 1 && arr[i].pos < current)left.push_back(arr[i]);
else if (arr[i].direct == -1 && arr[i].pos > current)right.push_back(arr[i]);
}
int l1 = left.size();
int l2 = right.size();
if (l1 == l2)cout << "Cannot fall!" << endl;
else if (l1 < l2) {
cout << right[l1].pos...
登录后发布评论
暂无评论,来抢沙发