题解
2024-12-09 21:18:14
发布于:广东
13阅读
0回复
0点赞
由题意得,最左边的高塔的编号为 .
所以我们只需要逐个枚举,找到第一个比 大的就输出就行了.
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main(){
cin.tie(nullptr) -> sync_with_stdio(0);
cout.tie(nullptr) -> sync_with_stdio(0);
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
if(i != 1 && a[i] > a[1]){//比它高
cout << i;
return 0;//不找了
}
}
cout << -1;//没找到
return 0;
}
全部评论 1
兄弟又是你!!!
2026-03-26 来自 上海
0对
2026-03-26 来自 广东
0依旧有智慧的兄弟
2026-03-26 来自 上海
0写得很好
2026-03-26 来自 上海
0













有帮助,赞一个