Submission #945693

# Submission time Handle Problem Language Result Execution time Memory
945693 2024-03-14T06:28:32 Z thelegendary08 Fancy Fence (CEOI20_fancyfence) C++17
30 / 100
1000 ms 14008 KB
#include<bits/stdc++.h>
#define vi vector<int>
#define vll vector<long long int>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<long long int, long long int>>
#define pb push_back
#define f0r(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef long long int ll;
const int mod = 1e9 + 7;
const int mxn = 1e5 + 5;
const int lg = floor(log2(mxn));
ll w[mxn];
ll h[mxn];
ll minh[lg][mxn];
ll c2(ll x){
    return x * (x+1) / 2 % mod;
}
ll ans(ll w, ll h){
    return c2(w) * c2(h) % mod;
}
ll minq(int l, int r){
    int sz = r - l + 1;
    int curlg = floor(log2(sz));

    return min(minh[curlg][l], minh[curlg][r - (int)pow(2, curlg) + 1]);
}
int main(){
    int n;
    cin>>n;
    f0r(i,n)cin>>h[i];
    f0r(i,n)cin>>w[i];
    f0r(i,n)minh[0][i] = h[i];
    for(int l = 1;l<=floor(log2(n));l++){
        f0r(i, n - pow(l, 2) + 1){
            minh[l][i] = min(minh[l-1][i], minh[l-1][i + (int)pow(l-1, 2)]);
        }
    }
    ll dp[n+1];
    dp[0] = ans(w[0], h[0]);

    for(int i = 1;i<n;i++){
        ll rm = h[i];
        ll thing = 0;
        for(int j = i-1;j>=0;j--){
            rm = min(rm, h[j]);
            thing += c2(rm) * w[j] % mod * w[i] % mod;
        }
        dp[i] = ((dp[i-1] + ans(w[i], h[i])) % mod + thing) % mod;
    }
    //for(auto u : dp)cout<<u<<' ';
    //cout<<'\n';
    cout<<dp[n-1];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 6 ms 8684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4552 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 4504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 4 ms 8540 KB Output is correct
3 Execution timed out 1059 ms 13916 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8540 KB Output is correct
2 Correct 298 ms 10996 KB Output is correct
3 Execution timed out 1058 ms 14008 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 5 ms 8540 KB Output is correct
3 Correct 293 ms 10992 KB Output is correct
4 Execution timed out 1020 ms 13912 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 6 ms 8540 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 4 ms 8540 KB Output is correct
9 Correct 5 ms 8540 KB Output is correct
10 Correct 5 ms 8672 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 3 ms 6492 KB Output is correct
13 Correct 5 ms 8796 KB Output is correct
14 Correct 5 ms 8540 KB Output is correct
15 Correct 5 ms 8688 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 6 ms 8684 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 5 ms 8540 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4588 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 5 ms 8540 KB Output is correct
11 Execution timed out 1036 ms 13916 KB Time limit exceeded
12 Halted 0 ms 0 KB -