dikki99's blog

By dikki99, history, 3 years ago, In English

this is my code link which is not accepted: https://mirror.codeforces.com/contest/233/submission/160186584

this is the code link which is accepted: https://mirror.codeforces.com/contest/233/submission/160187423

both on 10000000100000000 as the input are giving 100000000 as the output in my local ide, but somehow on running my previous solution on codeforces it is giving -1 as the output.

Full text and comments »

  • Vote: I like it
  • -16
  • Vote: I do not like it

By dikki99, history, 5 years ago, In English

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.

Full text and comments »

  • Vote: I like it
  • -40
  • Vote: I do not like it

By dikki99, history, 5 years ago, In English

link to the problem:-https://mirror.codeforces.com/contest/508/problem/C

please explain the logic behind this problem. I have looked into the editorial but it's not clear.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it