Submission #1838101


Source Code Expand

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define B 330
#define N 100010
ll res[N], s[N];
int main(){
	int n, m;
	cin>>n>>m;
	rep(i, n){
		int l, r;
		cin>>l>>r;
		int mn = INF;
		for(int j = 1; j < B; j++){
			int a = (l+j-1)/j, b = r/j;
			if(a<=b){
				res[j]++;
				b = min(b, mn-1);
				a = max(a, B);
				if(a<=b){
					s[a]++;
					s[b+1]--;
					mn = min(mn, a);
				}
			}
		}
	}
	rep(i, N-1) s[i+1] += s[i];
	rep(i, N) res[i] += s[i];
	rep(i, m) cout<<res[i+1]<<endl;
	return 0;
}

Submission Info

Submission Time
Task E - Snuke Line
User Lepton
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1636 Byte
Status AC
Exec Time 1049 ms
Memory 2432 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 2
AC × 39
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
All 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 2 ms 1792 KB
00_example_02.txt AC 2 ms 1792 KB
01.txt AC 2 ms 1792 KB
02.txt AC 8 ms 1792 KB
03.txt AC 3 ms 1792 KB
04.txt AC 2 ms 1792 KB
05.txt AC 4 ms 1792 KB
06.txt AC 4 ms 1792 KB
07.txt AC 2 ms 1792 KB
08.txt AC 4 ms 1792 KB
09.txt AC 4 ms 1792 KB
10.txt AC 2 ms 1792 KB
11.txt AC 889 ms 2048 KB
12.txt AC 980 ms 2432 KB
13.txt AC 818 ms 1792 KB
14.txt AC 806 ms 1792 KB
15.txt AC 808 ms 1792 KB
16.txt AC 869 ms 1920 KB
17.txt AC 978 ms 2432 KB
18.txt AC 825 ms 1792 KB
19.txt AC 982 ms 2432 KB
20.txt AC 988 ms 2432 KB
21.txt AC 982 ms 2432 KB
22.txt AC 982 ms 2432 KB
23.txt AC 983 ms 2432 KB
24.txt AC 1038 ms 2176 KB
25.txt AC 847 ms 1792 KB
26.txt AC 809 ms 1792 KB
27.txt AC 1049 ms 2176 KB
28.txt AC 862 ms 1920 KB
29.txt AC 1037 ms 2176 KB
30.txt AC 855 ms 1920 KB
31.txt AC 1000 ms 2432 KB
32.txt AC 861 ms 1920 KB
33.txt AC 831 ms 1792 KB
34.txt AC 1014 ms 2432 KB
35.txt AC 1011 ms 2432 KB
36.txt AC 2 ms 1792 KB
37.txt AC 156 ms 2048 KB