답안 #745932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745932 2023-05-21T09:45:29 Z vjudge1 Fancy Fence (CEOI20_fancyfence) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;


int main(){
    long long n; cin >> n;
    long long x, e, hossz;
    long long ans = 0;
    vector<long long> w, h;
    long long wsum = 0;
    for(long long i = 0; i < n; i++){
        cin >> x;
        h.push_back(x);
    }

    for(long long i = 0; i < n; i++){
        cin >> x;
        wsum += x;
        w.push_back(x);
    }

    hossz = (h[0]-1)*w[0];
    for(int i = 1; i < n; i++){
        if(h[i] == 2){
            hossz += w[i];
        }
        else if(h[i-1] == 2){
     //       cout << hossz << " ";
            ans += hossz*(hossz+1);
            ans = ans % 1000000007;
            hossz = 0;
        }
    }
 //   cout << hossz << " ";
    ans += hossz*(hossz+1); 
    ans = ans % 1000000007;
    
    ans += wsum*(wsum+1)/2;
    ans = ans % 1000000007;

    cout << ans;
}

Compilation message

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:7:18: warning: unused variable 'e' [-Wunused-variable]
    7 |     long long x, e, hossz;
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -