Submission #857901


Source Code Expand

#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

const LL mod = 1e9+7;

int main()
{
	ios_init();
	int n;
	cin >> n;
	vector<LL> p(n);
	vector<int> l(n);
	REP(i,n) cin >> p[i] >> l[i];
	vector<vector<LL>> dp(n);
	{
		dp[0].resize(2*l[0]+1,1);
	}
	FOR(i,1,n){
		LL dis = p[i]-l[i];
		LL pdis = p[i-1]-l[i-1];
		dp[i].resize(2*l[i]+1,0);
		vector<LL> sum(2*l[i-1]+2,0);
		sum[0] = 0;
		REP(j,2*l[i-1]+1) sum[j+1] = (sum[j]+dp[i-1][j])%mod;
		dpite(ALL(sum));
		int po = 0;
		REP(j,2*l[i]+1){
			while(po < 2*l[i-1]+1 and pdis+po < dis+j) po++;
			DEBUG(j); DEBUG(po);
			{
				dp[i][j] = (sum[po]-sum[0]+mod)%mod;
			}
		}
	}
	// REP(i,n) dpite(ALL(dp[i]));
	LL ans = 0;
	RBP(e,dp[n-1]) ans = (ans+e)%mod;
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task B - ぽよぽよ
User sntea
Language C++11 (GCC 4.8.1)
Score 100
Code Size 2210 Byte
Status AC
Exec Time 63 ms
Memory 8808 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 51
Set Name Test Cases
All 00-sample-00, 00-sample-01, handmade-00, largest-00, largest-01, largest-02, largest-03, largest-04, largest-05, random-00-0499, random-01-0439, random-02-0683, random-03-0329, random-04-0177, random-05-0106, random-06-0659, random-07-0421, random-08-0087, random-09-0455, random-10-0777, random-11-0148, random-12-0737, random-13-0119, random-14-0513, random-15-0237, random-16-0988, random-17-0322, random-18-0152, random-19-0612, random-20-0789, random-21-0213, random-22-0291, random-23-0159, random-24-0618, random-25-0601, random-26-0726, random-27-0491, random-28-0324, random-29-0429, random-30-0825, random-31-0645, random-32-0108, random-33-0203, random-34-0802, random-35-0155, random-36-0458, random-37-0674, random-38-0551, random-39-0063, random-40-0026, random-41-0545
Case Name Status Exec Time Memory
00-sample-00 AC 30 ms 936 KB
00-sample-01 AC 27 ms 1044 KB
handmade-00 AC 27 ms 1044 KB
largest-00 AC 63 ms 8744 KB
largest-01 AC 60 ms 8808 KB
largest-02 AC 61 ms 8672 KB
largest-03 AC 59 ms 8740 KB
largest-04 AC 60 ms 8744 KB
largest-05 AC 58 ms 8676 KB
random-00-0499 AC 29 ms 1000 KB
random-01-0439 AC 30 ms 1036 KB
random-02-0683 AC 27 ms 1000 KB
random-03-0329 AC 26 ms 992 KB
random-04-0177 AC 27 ms 928 KB
random-05-0106 AC 27 ms 1048 KB
random-06-0659 AC 27 ms 936 KB
random-07-0421 AC 26 ms 1048 KB
random-08-0087 AC 27 ms 940 KB
random-09-0455 AC 27 ms 968 KB
random-10-0777 AC 30 ms 1176 KB
random-11-0148 AC 29 ms 1008 KB
random-12-0737 AC 27 ms 992 KB
random-13-0119 AC 28 ms 876 KB
random-14-0513 AC 27 ms 1176 KB
random-15-0237 AC 30 ms 1048 KB
random-16-0988 AC 31 ms 1128 KB
random-17-0322 AC 29 ms 1000 KB
random-18-0152 AC 26 ms 1040 KB
random-19-0612 AC 29 ms 1124 KB
random-20-0789 AC 30 ms 1196 KB
random-21-0213 AC 29 ms 992 KB
random-22-0291 AC 29 ms 1000 KB
random-23-0159 AC 29 ms 1040 KB
random-24-0618 AC 30 ms 1124 KB
random-25-0601 AC 29 ms 1176 KB
random-26-0726 AC 29 ms 1132 KB
random-27-0491 AC 30 ms 1116 KB
random-28-0324 AC 27 ms 1172 KB
random-29-0429 AC 27 ms 1132 KB
random-30-0825 AC 30 ms 1304 KB
random-31-0645 AC 30 ms 1188 KB
random-32-0108 AC 29 ms 1048 KB
random-33-0203 AC 29 ms 1044 KB
random-34-0802 AC 30 ms 1320 KB
random-35-0155 AC 27 ms 1048 KB
random-36-0458 AC 29 ms 1132 KB
random-37-0674 AC 30 ms 1256 KB
random-38-0551 AC 28 ms 1188 KB
random-39-0063 AC 28 ms 1040 KB
random-40-0026 AC 29 ms 1036 KB
random-41-0545 AC 30 ms 1248 KB
sample-00 AC 26 ms 872 KB
sample-01 AC 30 ms 936 KB