直接输出ans1 188ptsWA on #4 #7 # 21
输出ans1 + 1 92pts 仅对 #4 #7 #21
说明主体代码没出问题,那么问题出在哪呢?
码
#include <bits/stdc++.h>
using namespace std;
int d[100005], ans1, ans2, a, w;
vector <int> f1;
vector <int> f2;
int main(){
while (cin>>a){
d[w++] = a;
}
f1.push_back(d[1]);
f2.push_back(d[1]);
for(int i = 2; i <= w ; i++){
if(d[i] <= f1[ans1]){
f1.push_back(d[i]);
ans1++;
}
else {
int p = upper_bound(f1.begin(), f1.end(), d[i], greater<int> ()) - f1.begin();
f1[p] = d[i];
}
if(d[i] > f2[ans2]){
f2.push_back(d[i]);
ans2++;
}
else {
int q = lower_bound(f2.begin(), f2.end(), d[i]) - f2.begin();
f2[q] = d[i];
}
}
printf("%d %d",ans1 + 1, ans2 + 1);//----注意这里!
return 0;
}