測資都過了, 但記憶體的問題是甚麼啊???
難道是陣列爆了?
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main(){
int n, m=0;
while( cin>>n ){
m++;
int arr[n];
bool flag=true;
for( int i=0; i<n; i++ ) cin>>arr[i];
for( int i=0; i<n-1; i++ )
if( arr[i]>=arr[i+1] ) flag=false;
vector <int>vec;
for( int i=0; i<n-1; i++ )
for( int j=i; j<n; j++ )
vec.push_back(arr[i]+arr[j]);
sort(vec.begin(), vec.end() );
for( int i=0; i<vec.capacity()-2*n+1; i++ )
if( vec[i]==vec[i+1] ) flag=false;
if( flag ) cout << "Case #" << m << ": It is a B2-Sequence." << endl;
else cout << "Case #" << m << ": It is not a B2-Sequence." << endl;
}
return 0;
}