제출 #580184

#제출 시각아이디문제언어결과실행 시간메모리
580184MODDIFancy Fence (CEOI20_fancyfence)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define vi vector<int> #define vl vector<ll> #define mp make_pair #define pb push_back using namespace std; const int MOD = 1e9 + 7; int main(){ int n; cin>>n; vl visina, sirina; for(int i = 0; i < n; i++){ ll a; cin>>a; visina.pb(a); } for(int i = 0; i < n; i++){ ll a; cin>>a; sirina.pb(a); } ll rez = 0, cur = 0, sum = 0; for(int i = 0; i < n; i++){ if(visina[i] == 1){ if(cur > 0){ cur%=MOD; rez += (cur * (cur + 1)) / 2; cur = 0; } } else{ cur+=sirina[i]; sum += sirina[i]; sum %= MOD; cur%=MOD; } } sum %= MOD; rez += (sum *(sum + 1)) /2; cout<<rez<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...