52102023-04-22 18:01:41SleepyOverlordGladiátorok (40 pont)cpp17Accepted 40/4074ms28476 KiB
#include <vector>
#include <string> 
#include <set> 
#include <map> 
#include <unordered_set>
#include <unordered_map>
#include <queue> 
#include <bitset> 
#include <stack>
#include <list>

#include <numeric> 
#include <algorithm> 
#include <random>
#include <chrono>

#include <cstdio>
#include <fstream>
#include <iostream> 
#include <sstream> 
#include <iomanip>
#include <climits>

#include <cctype>
#include <cmath> 
#include <ctime>
#include <cassert>

using namespace std;

#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap

#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)

#define SZ size()
#define BG begin() 
#define EN end() 
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count

int n, q;
VPII a;
VLL prefMax;

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	cin >> n >> q;
	a.RS(n + 1);
	prefMax.RS(n + 1);

	FOR(i, 1, n) cin >> a[i].X >> a[i].Y;
	sort(a.BG + 1, a.EN);
	LL sum = 0;
	FOR(i, 1, n)
	{
		prefMax[i] = max(prefMax[i - 1], a[i].X - sum);
		sum += a[i].Y;
	}
	FOR(i, 1, q)
	{
		int x;
		cin >> x;
		cout << upper_bound(ALL(prefMax), x) - prefMax.BG - 1 << " ";
	}

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1896 KiB
2Accepted0/014ms3308 KiB
3Accepted2/23ms2692 KiB
4Accepted2/23ms2916 KiB
5Accepted2/24ms3300 KiB
6Accepted2/24ms3580 KiB
7Accepted2/24ms3872 KiB
8Accepted2/24ms3996 KiB
9Accepted2/24ms4024 KiB
10Accepted2/24ms4100 KiB
11Accepted2/212ms5184 KiB
12Accepted2/252ms9296 KiB
13Accepted2/248ms9288 KiB
14Accepted2/274ms13468 KiB
15Accepted2/272ms15988 KiB
16Accepted2/272ms18656 KiB
17Accepted2/272ms20872 KiB
18Accepted2/254ms22292 KiB
19Accepted2/254ms23900 KiB
20Accepted2/254ms25316 KiB
21Accepted2/257ms26880 KiB
22Accepted2/257ms28476 KiB