Submission #745793

# Submission time Handle Problem Language Result Execution time Memory
745793 2023-05-21T07:53:21 Z vjudge1 Fancy Fence (CEOI20_fancyfence) C++14
12 / 100
1000 ms 296 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int MOD = 1e9 +7;

int binpow(int a, int b){
    int ans = 1;
    while(b != 0){
        if(b & 1){
            ans = ans * a % MOD;
        }
        a = a * a % MOD;
        b /= 2;
    }
    return ans;
}

signed main() {
    int n;
    cin >> n;
    vector<int> h(n), w(n);
    int cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    for(int i = 0; i < n; i++){
        cin >> w[i];
    }
    int dv = binpow(2, MOD - 2);
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= h[i]; j++){
            int k = i;
            while(k < n - 1 && h[k + 1] >= j){
                k++;
            }
            k = k - i + 1;
            ans = (ans + j * k) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Compilation message

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:24:9: warning: unused variable 'cnt' [-Wunused-variable]
   24 |     int cnt = 0;
      |         ^~~
fancyfence.cpp:31:9: warning: unused variable 'dv' [-Wunused-variable]
   31 |     int dv = binpow(2, MOD - 2);
      |         ^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -