vp时间
A.贪心,如果a[i]==ans;ans++;b[i]==(ans!=a[i])(直到这个条件成立就可以判断下一个a[i]);ans就是b[n].每次还会增加ans++;不成立也会ans++(模拟b[i]选择的元素),因此cout<<ans-1;
1.ac
B. 没思路
C.奇数取出,偶数删除.
ll ans=0;
if(!ans)cout<<ans<<'\n';
把大于0的数都存到一个结构体排序,2个结构体变量(x,index)一个大小,一个位置.从最大的数开始判断.
如果只有一个大于0的数在index=2,max(0,a[1]+a[2],a[1]);
貌似只需要特判一下a[1],a[2]这块即可,其他位置都可以直接拿到最大
1.wa2(数据范围 开ll)
2.ac
A.
// Problem: A. Increasing Sequence
// Contest: Codeforces - Codeforces Round 899 (Div. 2)
// URL: https://codeforces.com/contest/1882/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
//へ /|
// /\7 ∠_/
// / │ / /
// │ Z _,< / /`ヽ
// │ ヽ / 〉
// Y ` / /
// イ● 、 ● ⊂⊃〈 /
// () へ | \〈
// >ー 、_ ィ │ //
// / へ / ノ<| \\
// ヽ_ノ (_/ │//
// 7 |/
// >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N],b[N];
void solve() {
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int ans=1;
for(int i=1;i<=n;i++){
if(a[i]==ans){
ans++;
}
ans++;
}
cout<<ans-1<<'\n';
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int q;
cin >> q;
while (q--) {
solve();
}
return 0;
}
1
B.
set,map;
C.
// Problem: C. Card Game
// Contest: Codeforces - Codeforces Round 899 (Div. 2)
// URL: https://codeforces.com/contest/1882/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
//へ /|
// /\7 ∠_/
// / │ / /
// │ Z _,< / /`ヽ
// │ ヽ / 〉
// Y ` / /
// イ● 、 ● ⊂⊃〈 /
// () へ | \〈
// >ー 、_ ィ │ //
// / へ / ノ<| \\
// ヽ_ノ (_/ │//
// 7 |/
// >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
void solve() {
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
ll ans=0;
for(int i=3;i<=n;i++){
ans+=max(0,a[i]);
}
ll num=0;
if(n>1){
num=max(a[1],a[1]+a[2]);
}else{
num=a[1];
}
cout<<max(ans,ans+num)<<'\n';
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int q;
cin >> q;
while (q--) {
solve();
}
return 0;
}