제출 #1125694

#제출 시각아이디문제언어결과실행 시간메모리
1125694EfeBabagilFancy Fence (CEOI20_fancyfence)C++20
0 / 100
1 ms324 KiB
#include <bits/stdc++.h> #include <stdio.h> using namespace std; #define int long long int mod=1e9+7; int32_t main() { int n; cin>>n; vector<pair<int,int>> fences(n); int ans=0; for(int i=0;i<n;i++) { cin>>fences[i].first; } int sum=0; for(int i=0;i<n;i++) { cin>>fences[i].second; sum=(sum+fences[i].second)%mod; } int col; col=(((sum+1)*sum)/2)%mod; ans+=col; int x=0; for(int i=0;i<n;i++) { if(fences[i].first==2) { x=(fences[i].second+x)%mod; } if(fences[i].first==1) { ans+=(((x+1)*x))%mod; x=0; } } ans+=(((x+1)*x))%mod; cout<<ans; return 0; }
#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...