Submission #1199531

#TimeUsernameProblemLanguageResultExecution timeMemory
1199531thewizardmanFancy Fence (CEOI20_fancyfence)C++20
0 / 100
5 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll n, h[100001], w[100001], dp[100001], md = 1e9+7, ans; vector<pair<ll, ll>> v; ll bruh(ll a, ll b) { return ((a * b) / 2ll) % md; } int main() { scanf("%lld", &n); for (int i = 0; i < n; i++) scanf("%lld", h+i), h[i]++; for (int i = 0; i < n; i++) scanf("%lld", w+i), w[i]++; for (int i = 0; i < n; i++) { ll consec = 0; while (!v.empty() && v.back().first > h[i]) consec += v.back().second, v.pop_back(); v.push_back({h[i], consec + w[i]}); ll k = 0, asdf = 0; for (auto it = v.rbegin(); it != v.rend(); it++) { auto [h, w] = *it; ans = (ans + bruh(h, h-1) * bruh(w+k, w-1)) % md; k += w; } } printf("%lld", ans); }

Compilation message (stderr)

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%lld", &n);
      |   ~~~~~^~~~~~~~~~~~
fancyfence.cpp:14:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   for (int i = 0; i < n; i++) scanf("%lld", h+i), h[i]++;
      |                               ~~~~~^~~~~~~~~~~~~
fancyfence.cpp:15:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   for (int i = 0; i < n; i++) scanf("%lld", w+i), w[i]++;
      |                               ~~~~~^~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...