Submission #898396

# Submission time Handle Problem Language Result Execution time Memory
898396 2024-01-04T15:36:14 Z LCJLY Fancy Fence (CEOI20_fancyfence) C++14
30 / 100
26 ms 3932 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl; 
#define show4(x,y) for(auto it:x) cout << it << " "; cout << #y << endl;
typedef pair<int,int>pii;
typedef pair<pii,pii>pi2;

int mod=1e9+7;
int f(int a, int b){
	a%=mod;
	b%=mod;
	return (a*b)%mod;
}

int calc(int n){
	int hold=f(f(n,n+1),500000004);
	return hold;
}

int len(int a, int b){
	return b-a+1;
}

void solve(){	
	int n;
	cin >> n;

	pii arr[n];
	for(int x=0;x<n;x++){
		cin >> arr[x].first;
	}
	
	int w=0;
	for(int x=0;x<n;x++){
		cin >> arr[x].second;
		w+=arr[x].second;
	}
	
	int last=0;
	int counter=0;
	int pos=1;
	for(int x=0;x<n;x++){
		if(arr[x].first>last){
			int hold=(calc(arr[x].first)-calc(last)+mod)%mod;
			counter=(counter+f(hold,calc(len(pos,w))))%mod;
			last=arr[x].first;
		}
		pos+=arr[x].second;
		//show(counter,counter);
	}
	
	counter%=mod;
	
	cout << counter;
}
 
int32_t main(){										
	ios::sync_with_stdio(0);	
	cin.tie(0);
	//freopen("redistricting.in", "r", stdin);
	//freopen("redistricting.out", "w", stdout);
	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}	
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 8 ms 1228 KB Output is correct
4 Correct 15 ms 1884 KB Output is correct
5 Correct 17 ms 1884 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 8 ms 1116 KB Output is correct
5 Correct 17 ms 2012 KB Output is correct
6 Correct 16 ms 1884 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 4 ms 604 KB Output is correct
9 Correct 10 ms 2112 KB Output is correct
10 Correct 25 ms 3676 KB Output is correct
11 Correct 26 ms 3932 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -