Submission #959874

#TimeUsernameProblemLanguageResultExecution timeMemory
959874penguin133Fancy Fence (CEOI20_fancyfence)C++17
25 / 100
19 ms4700 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pi pair <int, int> #define pii pair <int, pi> int n, H[100005], W[100005], P[100005]; stack <pi> s; int lst[105]; const int mod = 1e9 + 7; void solve(){ cin >> n; for(int i = 1; i <= n; i++)cin >> H[i]; for(int i = 1; i <= n; i++)cin >> W[i]; s.push({0, 0}); int ans = 0; for(int i = 1; i <= n; i++){ P[i] = P[i - 1] + W[i]; P[i] %= mod; for(int j = H[i] + 1; j <= 100; j++)lst[j] = P[i]; for(int j = 1; j <= H[i]; j++){ ans += j * W[i] % mod * (P[i - 1] - lst[j] + mod) % mod; ans %= mod; int a = W[i] * (W[i] + 1) / 2; a %= mod; a *=j; a %= mod; ans += a; ans %= mod; } //cout << ans << '\n'; } cout << ans; } main(){ ios::sync_with_stdio(0);cin.tie(0); int tc = 1; //cin >> tc; while(tc--)solve(); }

Compilation message (stderr)

fancyfence.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main(){
      | ^~~~
#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...