Submission #857900


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.at(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 0
Code Size 2214 Byte
Status RE
Exec Time 310 ms
Memory 1768 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 3
RE × 48
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 43 ms 1460 KB
00-sample-01 AC 35 ms 1452 KB
handmade-00 AC 35 ms 1452 KB
largest-00 RE 297 ms 1624 KB
largest-01 RE 293 ms 1652 KB
largest-02 RE 298 ms 1712 KB
largest-03 RE 287 ms 1712 KB
largest-04 RE 292 ms 1712 KB
largest-05 RE 293 ms 1584 KB
random-00-0499 RE 288 ms 1768 KB
random-01-0439 RE 299 ms 1644 KB
random-02-0683 RE 300 ms 1592 KB
random-03-0329 RE 306 ms 1596 KB
random-04-0177 RE 300 ms 1640 KB
random-05-0106 RE 294 ms 1580 KB
random-06-0659 RE 293 ms 1708 KB
random-07-0421 RE 291 ms 1584 KB
random-08-0087 RE 289 ms 1576 KB
random-09-0455 RE 297 ms 1584 KB
random-10-0777 RE 296 ms 1584 KB
random-11-0148 RE 295 ms 1584 KB
random-12-0737 RE 292 ms 1580 KB
random-13-0119 RE 293 ms 1584 KB
random-14-0513 RE 297 ms 1584 KB
random-15-0237 RE 295 ms 1596 KB
random-16-0988 RE 293 ms 1580 KB
random-17-0322 RE 294 ms 1584 KB
random-18-0152 RE 290 ms 1588 KB
random-19-0612 RE 286 ms 1644 KB
random-20-0789 RE 296 ms 1640 KB
random-21-0213 RE 303 ms 1588 KB
random-22-0291 RE 294 ms 1588 KB
random-23-0159 RE 298 ms 1576 KB
random-24-0618 RE 302 ms 1724 KB
random-25-0601 RE 310 ms 1592 KB
random-26-0726 RE 294 ms 1584 KB
random-27-0491 RE 294 ms 1584 KB
random-28-0324 RE 293 ms 1552 KB
random-29-0429 RE 304 ms 1564 KB
random-30-0825 RE 291 ms 1688 KB
random-31-0645 RE 294 ms 1752 KB
random-32-0108 RE 289 ms 1520 KB
random-33-0203 RE 297 ms 1560 KB
random-34-0802 RE 290 ms 1652 KB
random-35-0155 RE 291 ms 1568 KB
random-36-0458 RE 297 ms 1564 KB
random-37-0674 RE 292 ms 1564 KB
random-38-0551 RE 294 ms 1560 KB
random-39-0063 RE 290 ms 1520 KB
random-40-0026 RE 286 ms 1564 KB
random-41-0545 RE 292 ms 1564 KB
sample-00 AC 35 ms 1432 KB
sample-01 AC 34 ms 1424 KB