| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1314855 | cubed | Progression (NOI20_progression) | C++20 | 1 ms | 332 KiB |
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define f first
// #define s second
#define pb(x) push_back(x)
#define int long long
const int MOD = 1e9+7;
const int inf = 1e9;
const int INF = 1e18+20;
const int LOG = 25;
int n;
vector<int> a;
int tt (int l, int r) {
int len = r-l+1;
if (len==1) return len;
int ans=2;
int L=l;
for (int R=l+1; R<=r; R++) {
if (R==L+1) continue;
if (a[R] - a[R-1] != a[L+1] - a[L]) {
L=R-1;
}
ans = max(ans, R-L+1);
}
return ans;
}
void solve() {
int q;
cin>>n>>q;
a.resize(n);
for (int i=0; i<n; i++) {
cin>>a[i];
}
while (q--) {
int type;
cin>>type;
if (type==1) {
int l, r, s, c;
cin>>l>>r>>s>>c;
l--; r--;
for (int i=l; i<=r; i++) {
a[i]+= (s + (i-l)*c);
}
} else if (type == 2) {
int l, r, s, c;
cin>>l>>r>>s>>c;
l--; r--;
for (int i=l; i<=r; i++) {
a[i] = (s + (i-l)*c);
}
} else {
int l, r;
cin>>l>>r;
l--; r--;
cout<<tt(l, r)<<endl;
}
}
}
bool multi=false;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t=1;
if (multi) cin>>t;
while (t--) solve();
return 0;
}
컴파일 시 표준 에러 (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... | ||||
