Submission #689656

#TimeUsernameProblemLanguageResultExecution timeMemory
689656saayan007Progression (NOI20_progression)C++17
15 / 100
3093 ms3688 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pi = pair<int, int>; using pl = pair<long long, long long>; using vi = vector<int>; using vl = vector<long long>; using vpi = vector<pair<int, int>>; using vpl = vector<pair<long long, long long>>; #define fur(i, a, b) for(ll i = a; i <= (ll)b; ++i) #define ruf(i, a, b) for(ll i = a; i >= (ll)b; --i) #define fr first #define sc second #define mp make_pair #define pb push_back #define eb emplace_back #define nl "\n" #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() const ll mxn = 3e5L + 1; ll n, q; ll d[mxn]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> q; fur(i, 1, n) { cin >> d[i]; } while(q--) { ll t; cin >> t; if(t == 1) { ll l, r, s, c; cin >> l >> r >> s >> c; fur(i, l, r) { d[i] += s + (i - l) * c; } } else if(t == 2) { ll l, r, s, c; cin >> l >> r >> s >> c; fur(i, l, r) { d[i] = s + (i - l) * c; } } else if(t == 3) { ll l, r; cin >> l >> r; ll ans = 1; ll i = l; while(i < r) { ll j = i + 1; ll diff = d[j] - d[i]; while(j + 1 <= r && d[j + 1] - d[j] == diff) { ++j; } ans = max(ans, j - i + 1); i = j; } cout << ans << nl; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...