Submission #847948


Source Code Expand

Copy
/*
*/
#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>  
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <ctime>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-10
#define M_PI 3.141592653589793
#define bs 1000000007;
#define bsize 512

const int N = 233031;

using namespace std;

long long n, Q;
long long q[N];

vector<pair<long long, long long> > queries[N];

map<long long, long long> s, toadd;
map<long long, long long> ::iterator it;
long long res[N];

int main(){
	//freopen("beavers.in","r",stdin);
	//freopen("beavers.out","w",stdout);
	//freopen("F:/in.txt","r",stdin);
	//freopen("F:/output.txt","w",stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> n >> Q;
	for (int i = 1; i <= Q; i++)
	{
		cin >> q[i];
	}

	
	q[0] = n;

	s[q[Q]] = 1;

	for (int i = Q; i>=0; --i)
	{
		toadd.clear();
		while (true)
		{
			if (s.size() == 0)
				break;
			it = s.end();
			--it;
			long long val = (*it).first;
			long long times = (*it).second;
			if (val <= q[i])
				break;
			s.erase(it);
			toadd[q[i]] += val / q[i]*times;
			if (val%q[i])
				toadd[val%q[i]] += times;
		}
		for (it = toadd.begin(); it != toadd.end(); it++)
		{
			long long val = (*it).first;
			long long times = (*it).second;
			s[val] += times;
		}
		/*for (it = s.begin(); it != s.end(); it++)
		{
			cout << (*it).first << "%%" << (*it).second << endl;
		}
		cout << endl;*/
	}

	long long ttl = 0;

	for (it = s.begin(); it != s.end(); it++)
	{
		long long val = (*it).first;
		long long times = (*it).second;
		//cout << "@@" << val << " " << times << endl;
		res[val+1] += times;
		ttl += times;
	}

	/*for (int i = 1; i <= 5; i++)
	{
		cout << res[i] << " ";
	}
	cout << endl;
	*/
	//cout << ttl << endl;

	for (int i = 1; i <= n; i++)
	{
		ttl -= res[i];
		cout << ttl << "\n";
	}

	cin.get(); cin.get();
	return 0;
}

Submission Info

Submission Time
Task E - Sequential operations on Sequence
User LeBron
Language C++14 (GCC 5.4.1)
Score 1400
Code Size 2344 Byte
Status AC
Exec Time 343 ms
Memory 17792 KB

Compile Error

./Main.cpp:32:0: warning: "M_PI" redefined
 #define M_PI 3.141592653589793
 ^
In file included from /usr/include/c++/5/cmath:44:0,
                 from /usr/include/c++/5/complex:44,
                 from ./Main.cpp:9:
/usr/include/math.h:372:0: note: this is the location of the previous definition
 # define M_PI  3.14159265358979323846 /* pi */
 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1400 / 1400
Status
AC × 2
AC × 38
Set Name Test Cases
Sample s1.txt, s2.txt
All 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, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt AC 65 ms 7808 KB
02.txt AC 65 ms 7936 KB
03.txt AC 66 ms 7936 KB
04.txt AC 66 ms 7936 KB
05.txt AC 67 ms 7936 KB
06.txt AC 263 ms 15616 KB
07.txt AC 302 ms 17792 KB
08.txt AC 278 ms 17024 KB
09.txt AC 286 ms 14976 KB
10.txt AC 252 ms 15104 KB
11.txt AC 240 ms 15616 KB
12.txt AC 285 ms 16256 KB
13.txt AC 295 ms 15488 KB
14.txt AC 282 ms 15616 KB
15.txt AC 240 ms 15360 KB
16.txt AC 270 ms 15872 KB
17.txt AC 287 ms 16384 KB
18.txt AC 256 ms 16256 KB
19.txt AC 223 ms 15232 KB
20.txt AC 264 ms 15872 KB
21.txt AC 343 ms 12928 KB
22.txt AC 334 ms 14592 KB
23.txt AC 247 ms 14208 KB
24.txt AC 92 ms 7936 KB
25.txt AC 88 ms 7808 KB
26.txt AC 79 ms 6784 KB
27.txt AC 42 ms 6656 KB
28.txt AC 42 ms 6656 KB
29.txt AC 42 ms 6656 KB
30.txt AC 43 ms 6656 KB
31.txt AC 14 ms 5760 KB
32.txt AC 25 ms 5888 KB
33.txt AC 13 ms 5760 KB
34.txt AC 34 ms 7168 KB
35.txt AC 13 ms 5760 KB
36.txt AC 13 ms 5760 KB
s1.txt AC 13 ms 5760 KB
s2.txt AC 13 ms 5760 KB