this is my solution for problem E from Codeforces round 731(div3).can anybody tell why it is giving me a wrong output(I have tried dry running all the test cases for my code, but I am not able to find any mistake)

Revision en1, by abhinav700, 2021-07-12 10:46:52
#include "bits/stdc++.h"
using namespace std;
 
int main()
{
 long long int q;
 cin>>q;
 while(q--)
 {
     long long int n,k;
     cin>>n>>k;
     vector<long long int> pos(k);
     for(long long int i=1;i<=k;i++)
     {
         cin>>pos[i];
     }
     vector<long long int> temp(k);
     for(long long int i=1;i<=k;i++)
     cin>>temp[i];

    vector<long long int> output(n,1e8);
    
   for(long long int i=1;i<=n;i++)
   {
       for(long long int j=1;j<=k;j++)
       {
           output[i]=min(output[i],temp[j]+abs(pos[j]-i));
       }
   }

    for(long long int i=1;i<=n;i++)
    cout<<output[i]<<" ";

    cout<<endl;
     
 }   
 return 0;
}
Tags c++, #round #731, #problem e

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English abhinav700 2021-07-12 10:46:52 916 Initial revision (published)