# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
854405 | 2023-09-27T10:14:18 Z | pliam | Fancy Fence (CEOI20_fancyfence) | C++17 | 1 ms | 456 KB |
#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); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 1 ms | 456 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 456 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 1 ms | 456 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |