Comments

thanks!

Will u guys please add this in gym?

Team: queue_T_pie from VIT Pune

Members: YSlow L1419GHT IamDragonite

Regionals: Amritapuri (Mysore)

Preferences in probleset: no constructives,adhoc,heavy observation and geometry problems :)

→ Reply

U can solve C without DP using simple prefix and suffix sums

https://codeforces.me/contest/1498/submission/346971895

C messed up the whole contest, but D was saver

On AnteMortem → Depression, 21 month(s) ago
0

bhai hamari branch kyu allowed nahi hai :((((

Thanks buddy for the help! :)

Whats wrong with people , always giving iterative code is not a good idea , some questions have recursive code more intuitive to understand and moreover if u writing a blog on cf where all will see its better to add such codes which are more understandable and intuitive

Author of B must get death penalty for such shit crime

https://codeforces.me/contest/1237/submission/274033759

Another way of problem B using two stacks , u can optimize it by using array instead of map for hashing

B can be solved like this also ~~~~~

void Solve() { int n; cin >> n; vi a(n-1); cin >> a;

vi ans;
ans.pb(a[0]);
for(int i = 1; i < n-1; ++i) {

    int num = a[i] | a[i-1];
    if((ans.back() & num) != a[i-1]) {
      cout << -1 << nl;
       return ;
    }

    ans.pb(num);
}
ans.pb(a[n-2]);

cout << ans << nl;

}

~~~~~

include <bits/stdc++.h>

using namespace std; using namespace chrono;

define ll long long

define mod 1000000007

define nn "\n\n"

define pb emplace_back

define sz(x) int(x.size())

define all(x) x.begin(), x.end()

define watch(x) cout << #x << " = " << x << '\n'

define endl '\n'

int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

auto ssss = high_resolution_clock::now();
int T;
cin >> T;
for (int tc = 1; tc <= T; ++tc) {

    cout << "Test Case #" << tc << ":" << endl;
        int n , l , r;
        cin >> n >> l >> r;
        ll ans = 0 , sum = 0;
        vector<int> a(n);
        for(auto& x : a) cin >> x;

       int index = -1;
        for(int i = 0; i < n; ++i) {
         sum += a[i];
         if(sum >= l && sum <= r) {
             sum = 0 , ans++;
             continue;
         }
         else {
               index = (index == -1) ? i : index;
             i++;
             while(i < n && sum  <  l) {
                sum += a[i];
                i++;
             }

             while(index  < i && sum > r) {
                 sum -= a[index];
                 index++;
             }

             if(sum >= l && sum <= r) {
                sum = 0;
                ans++;
          index = -1;
             }
             i--;
         }
    }

    cout << ans << endl;       


    cout << nn;
}

auto eeee = high_resolution_clock::now(); duration duration_sec = duration_cast<duration>(eeee — ssss); cout << "Total time taken: " << duration_sec.count() << " seconds" << endl; return 0; }

Can anyone tell me why this code is not getting selected o 3rd ??

Top Reasons of Depression 1.Breakup 2.WA on div2 A

right!!