Submission #647572

#TimeUsernameProblemLanguageResultExecution timeMemory
647572x0rK blocks (IZhO14_blocks)C++17
0 / 100
1 ms212 KiB
#pragma GCC optimize ("O2") #include <bits/stdc++.h> #define ll long long #define ld long double #define fi first #define se second #define pll pair < ll, ll > #define pii pair < int, int > #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; const string NAME = ""; const string NAME2 = "TEST"; const ld ESP = 1e-9; const ll INF = 1e9 + 7; const ll LINF = 1E18; const ll nmax = 2e5; const ll MOD = 1e9 + 7; const ll base = 2309; void fre() { string finp = NAME + ".inp"; string fout = NAME + ".out"; freopen(finp.c_str(), "r", stdin); freopen(fout.c_str(), "w", stdout); } int n, k, a[100003], s[100003]; int main() { fast; cin >> n >> k; int maxa = -1; for (int i = 1; i <= n; i++) { cin >> a[i]; s[i] = s[i - 1] + a[i]; if (maxa == -1 || a[i] >= a[maxa]) maxa = i; } int res = INF; for (int i = 0; i <= min(k - 1, maxa - 1); i++) res = min(res, a[maxa] + s[i] + s[n] - s[n - k + 1 + i]); cout << res; }

Compilation message (stderr)

blocks.cpp: In function 'void fre()':
blocks.cpp:26:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  freopen(finp.c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
blocks.cpp:27:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  freopen(fout.c_str(), "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...