# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1109391 | ro9669 | Progression (NOI20_progression) | C++17 | 26 ms | 9288 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin() , v.end()
#define sz(v) int(v.size())
#define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
using namespace std;
typedef long long ll;
typedef pair<int , int> ii;
typedef pair<long long , int> lli;
const int maxN = int(2e5)+7;
int n , q; ll a[maxN] , b[maxN];
void solve(){
cin >> n >> q;
for (int i = 1 ; i <= n ; i++) cin >> a[i];
for (int i = 1 ; i <= q ; i++){
int t; cin >> t;
if (t == 1){
int l , r , s , c;
cin >> l >> r >> s >> c;
for (int i = l ; i <= r ; i++){
a[i] += 1ll * c * (i - l) + s;
}
}
if (t == 2){
int l , r , s , c;
cin >> l >> r >> s >> c;
for (int i = l ; i <= r ; i++){
a[i] = 1ll * c * (i - l) + s;
}
}
if (t == 3){
int l , r;
cin >> l >> r;
int ans = 1;
for (int i = l ; i < r ; i++) b[i] = a[i + 1] - a[i];
int i = l , j = i - 1;
while (i < r){
while (j + 1 < r && b[i] == b[j + 1]) j++;
ans = max(ans , j - i + 2);
i = j + 1;
}
cout << ans << "\n";
}
}
}
#define name "A"
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen(name".INP" , "r")){
freopen(name".INP" , "r" , stdin);
freopen(name".ans" , "w" , stdout);
}
int t = 1; //cin >> t;
while (t--) solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |