제출 #897033

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