vaibhav_314's blog

By vaibhav_314, history, 6 hours ago, In English

Introducing Contest Notifier — Your all-in-one solution to enhance your coding contest experience! This web extension centralizes and customizes your contest tracking, with smart reminders and time-based filtering to keep you on top of your game. You can explore the extension here and access the GitHub repository here.

Features We Provide:

  1. Centralized Contest Tracking: View upcoming and ongoing contests from platforms like LeetCode, CodeChef, Codeforces, AtCoder, GeeksforGeeks, and CodingNinjas all in one place.
  2. Customizable Platform & Time Selection: Filter contests by your preferred platforms and timeframes, such as ongoing or starting within the next 24 hours.
  3. Smart Reminder System: Receive a reminder 10 minutes before a contest begins when you’ve set an alarm. (Make sure your device's Do Not Disturb is off to receive notifications)

Privacy First: We don’t store any of your data. Contest Notifier simply fetches and displays contest information.

Found it useful? Share Contest Notifier with your friends!

Discover a bug? Help us improve! Report any issues in our Chrome extension for a smoother, better experience. Thank you!

Full text and comments »

  • Vote: I like it
  • +9
  • Vote: I do not like it

By vaibhav_314, 3 months ago, In English

Contest Link: Codeforces Round 944 (Div. 4)
Problem Link: 1971E - Find the Car
Submission: 260347418

Why does my solution gives wrong ans? I have cross validated the approach various times but still couldn't find what is wrong with my code.

Code:

#include <bits/stdc++.h>
using namespace std;

#define md 1000000007
#define pb push_back
#define endl " \n"
#define F first
#define S second
#define sz(x) (int)(x).size()
#define inp(v)        \
    for (auto &x : v) \
    cin >> x
#define all(x) (x).begin(), (x).end()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define fast_io                     \
    cin.tie(0)->sync_with_stdio(0); \
    cin.exceptions(cin.failbit);

using ll = long long;
using ull = unsigned long long;
using lld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vi = vector<int>;

void solve() {
    ll n,k,q;
    cin>>n>>k>>q;

    vl nums(k+1);
    nums[0] = 0;
    for (ll i=1;i<=k;i++) cin>>nums[i];

    vl time(k+1);
    time[0] = 0;
    for (ll i=1;i<=k;i++) cin>>time[i];

    for (ll i=0;i<q;i++) {
        ll x;
        cin>>x;
        ll left = 0,right = k, mid,result = 0;
        while (left <= right) {
            int mid = left + (right - left) / 2;

            if (nums[mid] <= x) {
                result = mid;
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }

        if (nums[result] == x) {
            cout<<time[result]<<" ";
        } else {
            double speed = 1.0*(nums[result+1] - nums[result])/(time[result+1] - time[result]);
            ll val = time[result] + floor((x - nums[result])/speed);
            // cout<<nums[result]<<" "<<speed<<" ";
            cout<<val<<" ";
        }

    }
    cout<<endl;
}

int main() {
    fast_io;

    int t = 1;
    cin >> t;
    for (int i = 0; i < t; i++)
        solve();
    return 0;
}

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it