| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1329686 | nguyenkhanghuy | Fancy Fence (CEOI20_fancyfence) | C++20 | 1 ms | 344 KiB |
//#include <bits/BaoMinhTranc++.h>
#include <bits/stdc++.h>
#define int int64_t
//#define ll int64_t
#define ld long double
#define ii pair<int,int>
#define iii pair<int,ii>
#define fi first
#define se second/
#define ALL(x) x.begin(),x.end()
#define ALLr(x) x.rbegin(),x.rend()
#define upgrade ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define name "FENCE"
using namespace std;
const int Max=1e2;
const int N=1e2+3;
const int INF=1e18;
const int MOD=1e9+7;
const int MOD2=1e9+8;
const int base=9;
const int LOG=30;
template<class X,class Y>
bool minimize(X& x,const Y& y)
{
if(x>y){
x=y;
return 1;
}return 0;
}
template<class X,class Y>
bool maximize(X& x,const Y& y)
{
if(x<y){
x=y;
return 1;
}return 0;
}
int n;
int h[N],w[N];
namespace sub23
{
int sum(int l,int r)
{
if(r<l)return 0;
int a=r-l+1,b=r+l;
if(a%2==0)a/=2;
else b/=2;
return a*b%MOD;
}
void solve()
{
for(int i=n;i>=1;i--)w[i]+=w[i+1];
int ans=0;
for(int i=1;i<=n;i++){
ans+=sum(1,h[i])*sum(1,w[i])%MOD;
ans-=sum(1,h[i-1])*sum(1,w[i])%MOD;
ans=(ans+MOD)%MOD;
}
cout<<ans;
}
}
signed main()
{
upgrade
if(fopen(name".INP","r")){
freopen(name".INP","r",stdin);
freopen(name".OUT","w",stdout);
}
cin>>n;
for(int i=1;i<=n;i++)cin>>h[i];
for(int i=1;i<=n;i++)cin>>w[i];
bool tt=1;
for(int i=1;i<=n;i++){
if(h[i]<h[i-1])tt=0;
}
if(tt)sub23::solve();
else cout<<"toibingu";
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
