Submission #2601237


Source Code Expand

#include "bits/stdc++.h"
using namespace std;

long long int y;  //number of weeks
long long int w;  //number of days for a week

int n;
int m;
long long int d;

vector<long long int> v;

map<long long int, vector<long long int> > mp;


multiset<long long int> mt;
long long int ans;

void ins(long long int day) {
	long long int lef = 0;
	long long int rig=0;
	{
		auto it = mt.lower_bound(day);
		lef = *prev(it);
		rig = (*it);
	}
	bool COV = ((rig - lef) <= d);
	bool f = (int)(mt.find(day)!=mt.end());
	mt.insert(day);
	if (f)return;
	if (!COV) {
		ans++;
		if ((day - lef) <= d) {
			ans += day - lef - 1LL;
		}
		if (rig - day <= d) {
			ans += rig - day - 1LL;
		}
	}
}
void del(long long int day) {
	mt.erase(mt.lower_bound(day));
	if (mt.find(day)!=mt.end())return;
	long long int lef = 0;
	long long int rig = 0;
	{
		auto it = mt.lower_bound(day);
		lef = *prev(it);
		rig = (*it);
	}
	ans--;
	if ((day - lef) <= d) {
		ans -= day - lef - 1LL;
	}
	if ((rig - day) <= d) {
		ans -= rig - day - 1LL;
	}
	if (rig - lef <= d) {
		ans += rig - lef - 1LL;
	}
}
long long int calc(long long int be_week,long long int week, long long int cn) {
	long long int ret = w*(cn-1LL);
	ret += week;
	if (be_week > week) {
		ret += w;
	}
//	cerr <<"be_week "<<be_week<<" week "<<week<<" cn "<<cn<<" ans "<< ret << endl;
	return ret;
}
int main() {
	mt.insert(-1145141919810893LL);
	mt.insert(1145141919810893LL);
	ans = 0;
	cin >> y >> w;
	cin >> n >> m >> d;
	d++;
	for (int i = 0; i < n; i++) {
		long long int a;
		scanf("%lld", &a);
		v.push_back(a);
	}
	for (int i = 0; i < m; i++) {
		long long int b, c;
		scanf("%lld%lld", &b, &c);
		mp[c].push_back(b);
		ins(calc(1, c, b));
	}
	for (int i = 1; i <= w; i++) {
		for (int i1 = 0; i1 < v.size(); i1++) {
			ins(v[i1]+i-1LL);
		}
		if (mp.count(i-1)) {
			//er
			auto &it = mp[i-1];
			for (auto el : it) {
				if (i != 1) {
					del(calc(i-1,i-1,el));
					ins(calc(i, i - 1, el));
				}
			}
		}
		printf("%lld\n", ans);
		for (int i1 = 0; i1 < v.size(); i1++) {
			del(v[i1] + i-1LL);
		}
	}
	return 0;
}

Submission Info

Submission Time
Task E - 祝日
User Kmcode
Language C++14 (GCC 5.4.1)
Score 700
Code Size 2167 Byte
Status AC
Exec Time 4087 ms
Memory 16512 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:80:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &a);
                    ^
./Main.cpp:85:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &b, &c);
                            ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 600 / 600 100 / 100
Status
AC × 4
AC × 22
AC × 56
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
Subtask1 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, sample-01.txt, sample-02.txt
All 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt, 02-17.txt, 02-18.txt, 02-19.txt, 02-20.txt, 02-21.txt, 02-22.txt, 02-23.txt, 02-24.txt, 02-25.txt, 02-26.txt, 02-27.txt, 02-28.txt, 02-29.txt, 02-30.txt, 02-31.txt, 02-32.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
Case Name Status Exec Time Memory
01-01.txt AC 231 ms 13440 KB
01-02.txt AC 218 ms 11392 KB
01-03.txt AC 145 ms 9216 KB
01-04.txt AC 44 ms 3328 KB
01-05.txt AC 185 ms 7168 KB
01-06.txt AC 167 ms 6016 KB
01-07.txt AC 111 ms 7792 KB
01-08.txt AC 36 ms 3968 KB
01-09.txt AC 235 ms 11136 KB
01-10.txt AC 34 ms 2688 KB
01-11.txt AC 180 ms 12160 KB
01-12.txt AC 178 ms 10112 KB
01-13.txt AC 202 ms 12288 KB
01-14.txt AC 71 ms 4864 KB
01-15.txt AC 213 ms 8320 KB
01-16.txt AC 4 ms 256 KB
01-17.txt AC 41 ms 2048 KB
01-18.txt AC 185 ms 6144 KB
01-19.txt AC 231 ms 13440 KB
01-20.txt AC 223 ms 11904 KB
02-01.txt AC 1955 ms 15232 KB
02-02.txt AC 628 ms 8576 KB
02-03.txt AC 645 ms 13184 KB
02-04.txt AC 1248 ms 13568 KB
02-05.txt AC 2121 ms 13312 KB
02-06.txt AC 1042 ms 9984 KB
02-07.txt AC 111 ms 5744 KB
02-08.txt AC 310 ms 2048 KB
02-09.txt AC 1270 ms 12160 KB
02-10.txt AC 99 ms 2304 KB
02-11.txt AC 1498 ms 13568 KB
02-12.txt AC 478 ms 8960 KB
02-13.txt AC 591 ms 8448 KB
02-14.txt AC 101 ms 1664 KB
02-15.txt AC 502 ms 7936 KB
02-16.txt AC 20 ms 256 KB
02-17.txt AC 72 ms 2048 KB
02-18.txt AC 228 ms 6144 KB
02-19.txt AC 1608 ms 14208 KB
02-20.txt AC 70 ms 5748 KB
02-21.txt AC 304 ms 1024 KB
02-22.txt AC 2 ms 256 KB
02-23.txt AC 4087 ms 16512 KB
02-24.txt AC 2061 ms 12800 KB
02-25.txt AC 1317 ms 9216 KB
02-26.txt AC 2 ms 256 KB
02-27.txt AC 75 ms 384 KB
02-28.txt AC 295 ms 640 KB
02-29.txt AC 172 ms 5760 KB
02-30.txt AC 175 ms 5888 KB
02-31.txt AC 174 ms 5888 KB
02-32.txt AC 179 ms 512 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB
sample-03.txt AC 1 ms 256 KB
sample-04.txt AC 1 ms 256 KB