题解
2024-04-26 18:38:48
发布于:广东
36阅读
0回复
0点赞
记录差的绝对值
排个序
秒了
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100005], b[100005];
int main(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
b[i] = abs(a[i] - a[i - 1]);
}sort(b + 2, b + n + 1);
for(int i = 2; i <= n; i++){
if(b[i] != i - 1){
cout << "Not jolly";
return 0;
}
}cout << "Jolly";
return 0;
}
时间复杂度:
这里空空如也
有帮助,赞一个