# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
854405 | pliam | Fancy Fence (CEOI20_fancyfence) | C++17 | 1 ms | 456 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100005
typedef long long ll;
#define MOD (ll)1e9+7
#define INF (ll)2e9
/*
We have only height 1 and 2
We need to find all the consequtive ranges of 1 and 2
*/
int N, L;
ll h[MAXN], w[MAXN], sumw;
vector<ll> l1, l2;//lengths of ranges 1 and 2
int main(){
scanf("%d",&N);
for(int i=1;i<=N;i++){
scanf("%lld",&h[i]);
}
for(int i=1;i<=N;i++){
scanf("%lld",&w[i]);
sumw+=w[i];
if(h[i]==h[i-1]){
//existing range
if(h[i]==1){
l1.back()+=w[i];
}else{
l2.back()+=w[i];
}
}else{
//new range
if(h[i]==1){
l1.push_back(w[i]);
}else{
l2.push_back(w[i]);
}
}
}
ll ans=0;
ans+=(sumw*(sumw+1))/2LL;
for(ll l:l2){
ans+=l*(l+1);
}
printf("%lld\n", ans);
}
컴파일 시 표준 에러 (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... |