wrong judging by codeforces!!! when i am running this test case in my ide it is giving correct answer. This is not fair!!!

Правка en1, от dikki99, 2020-05-01 22:20:46

include

include<math.h>

include

using namespace std;

bool check(int* arr,int n,int k){ int sum=0; int curr=0; for(int i=0;i<k;i++) sum+=arr[i]; curr=sum; for(int i=k;i<n;i++){ curr+=arr[i]-arr[i-k]; if(curr!=sum) return false; } return true; }

int main(){ int t; cin>>t; while(t--){ int n,k; cin>>n>>k; int arr[n]; map<int,int> m; for(int i=0;i<n;i++){ cin>>arr[i]; m[arr[i]]++; } if(n==k){ cout<<k<<endl; for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<endl; } else if(m.size()>k||m.size()==n){ cout<<-1<<endl; } else if(check(arr, n, k)){ cout<<n<<endl; for(int i=0;i<n;i++){ cout<<arr[i]<<" "; } cout<<endl; } else{ cout<<n*m.size()<<endl; for(int i=0;i<n;i++){ for(map<int, int>::iterator itr=m.begin();itr!=m.end();itr++){ cout<first<<" "; } }

cout<<endl;
}

}// t; return 0; }

This is my code for DIV.2 b question and this giving wrong answer on 4th pretest but it is giving correct output on my local ide.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский dikki99 2020-05-01 22:20:46 1349 Initial revision (published)