Codeforces Round #797 (Div. 3) 1690C. Restoring the Duration of Tasks Solution

 



 

Problem Link: https://codeforces.com/contest/1690/problem/C

Solution in C++:

///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat  Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int  n,x,y,t,r,i;
    cin>>t;
    while(t--)
    {
        x=y=0;
        vector<int>v;
        cin>>n;
        int a[n+9],b[n+9];
        for(i=0; i<n; i++)cin>>a[i];
        for(i=0; i<n; i++)cin>>b[i];
        x=b[0]-a[0];
        v.push_back(x);
        for(i=1; i<n; i++)
        {
            if(b[i-1]<a[i])
            {
                x=b[i]-a[i];
                v.push_back(x);
            }
            else
            {
                x=b[i]-b[i-1];
                v.push_back(x);
            }
        }
        for(i=0;i<v.size();i++)
        {
            cout<<v[i]<<" ";
        }
        cout<<endl;
    }
}
















No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.