Submission #834257

#TimeUsernameProblemLanguageResultExecution timeMemory
834257unnickProgression (NOI20_progression)C++14
0 / 100
3022 ms9824 KiB
#include <iostream> #include <vector> using namespace std; int main(){ // The following line disables syncing between cin/scanf and cout/printf. // It makes input faster, but you must not use functions from <cstdio> (e.g. scanf/printf) directly. // This line must be executed before any use of cin/cout. ios_base::sync_with_stdio(false); // Your code goes here ... // (You can now read input and write output normally using cin/cout.) int N,Q; cin >> N >> Q; std::vector<int> arr; for (int i = 0; i < N; i++) { int tmp; cin >> tmp; arr.push_back(tmp); } for (int q = 0; q < Q; q++) { int op; cin >> op; int l,r,s,c; switch (op) { case 1: cin >> l >> r >> s >> c; for(int i = l; i <= r; i++) { arr[i-1] += s+(i-l)*c; } break; case 2: cin >> l >> r >> s >> c; for(int i = l; i <= r; i++) { arr[i-1] = s+(i-l)*c; } break; case 3: cin >> l >> r; // cout << "\n-- "; // for (int i = 0; i < N; i++) { // cout << arr[i] << " "; // } // cout << '\n'; if (l == r) { cout << 1; break; } int maxl = 1; int len = 0; int d = -1000000000; for (int i = l-1+1; i < r; i++) { int cd = arr[i] - arr[i-1]; if (d != cd) { if (maxl < len) maxl = len; len = 1; d = cd; } else len++; } if (maxl < len) maxl = len; cout << (maxl+1) << endl; break; } } }
#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...