Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
using namespace std; int main() { ios_base::sync_with_stdio(false); int n, k, s; cin >> n >> k >> s; int niza[n]; for(int i = 0; i < n; i++) { cin >> niza[i]; } long long sum = 0; for(int i = 0; i < k - 1; i++) { sum += niza[i]; } int i = 0; pair
p[n]; for(int j = k - 1; j < n; j++) { sum += niza[j]; p[i] = make_pair(sum, i); sum -= niza[i]; i++; } sort(p, p + i); long long res = 0; for(int j = i - 1; j >= max(0, i - 5000); j--) { long long s_sum = 0; int cnt = 1; for(int idx = p[j].second; idx < p[j].second + k; idx++) { if(cnt == s) { s_sum += niza[idx]; cnt = 0; } cnt++; } if(res < p[j].first - s_sum) { res = p[j].first - s_sum; } } cout << res << endl; return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)