# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
572517 | teki | Fancy Fence (CEOI20_fancyfence) | C++11 | 43 ms | 7536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define MN 1000000007
using namespace std;
ll n, curr = 0, res = 0, x = 0;
ll h[100001],w[100001];
ll calcZbir(ll w) {
w %= MN;
return (w*(w-1)/2)%MN;
}
int main()
{
#if LOCAL_DEBUG
fstream cin("in.txt");
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for (int i = 0; i<n; i++) cin>>h[i];
for (int i = 0; i<n; i++) cin>>w[i];
n++;
stack<pair<ll,ll>> st;
st.push({0,-1});
for (int i = 0; i<n; i++) {
vector<pair<ll,ll>> v2;
while(st.top().second >= h[i]) {
v2.pb(st.top());
st.pop();
v2.back().first -= st.top().first;
}
for (int j = 1; j<v2.size(); j++) v2[j].first += v2[j-1].first;
v2.pb({MN+1,h[i]});
for (int j = 0; j<v2.size()-1; j++) {
ll temp = v2[j].second-v2[j+1].second;
res += (calcZbir(v2[j].first+1))*(temp*v2[j+1].second%MN+calcZbir(temp+1));
res %= MN;
}
x += w[i];
st.push({x,h[i]});
}
cout<<res<<endl;
return 0;
}
컴파일 시 표준 에러 (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... |