제출 #1125701

#제출 시각아이디문제언어결과실행 시간메모리
1125701EfeBabagilFancy Fence (CEOI20_fancyfence)C++20
13 / 100
40 ms1864 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; //cout<<col<<"+"; ans=(ans+col)%mod; 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=(ans+(x+1)*x)%mod; //cout<<(((x+1)*x))%mod<<"+"; x=0; } } ans=(ans+(x+1)*x)%mod; //cout<<(((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...