专栏文章
5-8总结
个人记录参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mipdi6l7
- 此快照首次捕获于
- 2025/12/03 10:13 3 个月前
- 此快照最后确认于
- 2025/12/03 10:13 3 个月前
标题
第一题
错误代码
CPP/*
*/
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const int N = 2e5 + 10;
int main()
{
return 0;
}
正确代码
CPP/*
思路
/
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const int N = 2e5 + 10;
int a[200005], n, r=0;//r:最右边球的位置
int main(){
cin >> n;
while(n--){ //n次操作
int x; cin>>x;
a[++r] = x; // 1左移x位相当于 2^x
if(r<=1) continue;
else if(a[r]!=a[r-1]) continue;
else if(a[r]==a[r-1]){
while(r>=2 && a[r]==a[r-1]){
int t = a[r] + 1;
a[r-1] = t;
r--;
}
}
}
cout << r;
return 0;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...