# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1002131 | 2024-06-19T10:18:14 Z | alecurse | Fancy Fence (CEOI20_fancyfence) | C++17 | 2 ms | 604 KB |
#include <bits/stdc++.h> #define ll long long int #define mp make_pair using namespace std; ll mod = 1e9+7; int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); ll N; cin>>N; vector<ll> prefix(N+1); vector<ll> H(N+1), W(N+1); ll res=0; for(ll i=1;i<=N;i++) { cin>>H[i]; } for(ll i=1;i<=N;i++) { cin>>W[i]; prefix[i]=prefix[i-1]+W[i]; } vector<pair<ll,ll> > v(N); set<ll> s; for(ll i=1;i<=N;i++) { s.insert(i); v[i-1]=mp(H[i],i); } sort(v.rbegin(),v.rend()); s.insert(0); s.insert(N+1); for(ll t=0;t<N;t++) { ll index=v[t].second; s.erase(index); auto it= s.upper_bound(index); ll wd = prefix[*it-1]-prefix[index]; it=prev(it,1); ll ws = prefix[index-1]-prefix[*it]; ll w = W[index]; ll h = H[index]; ll sum=h*(h+(ll)1)/(ll)2; ll sumw=w*(w+(ll)1)/(ll)2; sum%=mod; sumw%=mod; ll toadd=0; toadd+=(ws*w)%mod; toadd%=mod; toadd+=(wd*w)%mod; toadd%=mod; toadd+=(wd*ws)%mod; toadd%=mod; toadd+=sumw; toadd%=mod; toadd*=sum; toadd%=mod; if(toadd<0) { while(true) { }; } res+=toadd; res%=mod; } cout<<res; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 604 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 496 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 604 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 604 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 604 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 600 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 604 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |