Submission #612362

#TimeUsernameProblemLanguageResultExecution timeMemory
612362cheissmartSeesaw (JOI22_seesaw)C++14
67 / 100
991 ms1048576 KiB
#include <bits/stdc++.h> #define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0); #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(v) int((v).size()) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; typedef long double db; string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m"; void DBG() { cerr << "]" << _reset << endl; } template<class H, class...T> void DBG(H h, T ...t) { cerr << to_string(h); if(sizeof ...(t)) cerr << ", "; DBG(t...); } #ifdef CHEISSMART #define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__) #else #define debug(...) #endif const int INF = 1e9 + 7, N = 2e5 + 6; const ll oo = 1e18; int a[N]; ll p[N]; signed main() { IO_OP; cout << fixed << setprecision(12); int n; cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; p[i] = p[i - 1] + a[i]; } auto go = [&] (int i, int j) { return db(p[j] - p[i - 1]) / (j - i + 1); }; V<pair<db, db>> aux; for(int len = 1; len <= n; len++) { for(int i = 1; i + len - 1 <= n; i++) { int j = i + len - 1; db he = go(i, j); db be = j + 1 <= n ? go(i + 1, j + 1) : oo; aux.EB(he, be); } } sort(ALL(aux)); db tt = go(1, n), ans = oo; for(auto[he, be]:aux) { ans = min(ans, tt - he); tt = max(tt, be); } cout << ans << '\n'; }

Compilation message (stderr)

seesaw.cpp: In function 'int main()':
seesaw.cpp:64:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   64 |  for(auto[he, be]:aux) {
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...