답안 #942343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942343 2024-03-10T13:16:08 Z batsukh2006 Fancy Fence (CEOI20_fancyfence) C++17
0 / 100
14 ms 488 KB
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
#include<utility>
#include<set>
#include<cmath>
#include<queue>
#include<deque>
#include<functional>
#include<stack>
#include<limits.h>
#include<iomanip>
#include<unordered_map> 
 
using namespace std;
 
#define MOD 1000000007
#define int long long
#define endl '\n'
int cal(int a, int b){
    int f=(a*(a+1))%MOD*((MOD+1)/2)%MOD;
    int s=(b*(b+1))%MOD*((MOD+1)/2)%MOD;
    return (f*s)%MOD;
}
void solve(){
    int n; cin>>n;
    vector<int> h(n+1),w(n+1);
    for(int i=1; i<=n; i++) cin>>h[i];
    for(int i=1; i<=n; i++) cin>>w[i];
    int ans=0;
    for(int i=1; i<=n; i++){
        int cur=0,mx=h[i];
        ans=(ans+cal(h[i],w[i]))%MOD;
        for(int j=i-1; j>=1; j--){
            mx=min(mx,h[j]);
            cur=(cur+w[j])%MOD;
            ans=(ans-cal(cur,mx)+MOD)%MOD;
            ans=(ans-cal(w[i],mx)+MOD)%MOD;
            ans=(ans+cal(cur+w[i],mx))%MOD;
        }
    }
    cout<<ans;
}
signed main(){
	// freopen("hps.in", "r", stdin);
	// freopen("hps.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int t=1;
	// cin>>t;
	while(t--){
		solve();
		cout<<endl;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 10 ms 488 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 11 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 11 ms 488 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 452 KB Output is correct
2 Incorrect 11 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 10 ms 488 KB Output isn't correct
3 Halted 0 ms 0 KB -