| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 790899 | 12345678 | Fancy Fence (CEOI20_fancyfence) | C++17 | 40 ms | 8776 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll nx=1e5+5, mod=1e9+7;
ll n, ans, h, w, sm, H[nx], W[nx];
stack<pair<pair<ll, ll>, ll>> s;
ll cal(ll x)
{
return (x*(x+1)/2)%mod;
}
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=0; i<n; i++) cin>>H[i];
for (int i=0; i<n; i++) cin>>W[i];
for (int i=0; i<n; i++)
{
ll h=H[i], w=W[i];
ans=(ans+(cal(h)*cal(w))%mod)%mod;
ll sw=0;
while (!s.empty()&&s.top().first.first>h)
{
sw+=s.top().first.second;
sm=((sm-s.top().second)%mod+mod)%mod;
s.pop();
}
ll tmp=(cal(h)*sw)%mod;
s.push({{h, sw}, tmp});
sm=(sm+tmp)%mod;
ans=(ans+sm*w)%mod;
tmp=(cal(h)*w)%mod;
s.push({{h, w}, tmp});
sm=(sm+tmp)%mod;
}
cout<<ans;
}| # | 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... | ||||
