제출 #897034

#제출 시각아이디문제언어결과실행 시간메모리
897034AndrijaM연결리스트 수사하기 (NOI12_forensic)C++17
0 / 25
315 ms1492 KiB
#include <bits/stdc++.h> using namespace std; int main() { long long n; vector<pair<long long,long long>>v; cin>>n; for(long long i=0;i<n;i++) { long long x,y; cin>>x>>y; v.push_back({x,y}); } long long dp[n][5]; memset(dp,0,sizeof dp); for(long long i=v[0].first;i<=v[0].second;i++) { dp[0][i%5]++; } for(long long i=1;i<n;i++) { for(long long mod=0;mod<5;mod++) { for(long long j=v[i].first;j<=v[i].second;j++) { dp[i][(mod+j)%5]+=dp[i-1][mod]; } } } /*for(long long i=0;i<n;i++) { for(long long mod=0;mod<5;mod++) { cout<<dp[i][mod]<<" "; } cout<<endl; }*/ cout<<4*(dp[n-1][1]+dp[n-1][4])+5*(dp[n-1][2]+dp[n-1][3])+dp[n-1][0]<<endl; 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...