Submission #847799


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;

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;
		toadd[val+1] += times;
		ttl += times;
	}

	//cout << ttl << endl;

	for (int i = 1; i <= n; i++)
	{
		ttl -= toadd[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 0
Code Size 2191 Byte
Status WA
Exec Time 355 ms
Memory 17664 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 0 / 1400
Status
AC × 2
AC × 10
WA × 28
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 WA 111 ms 14080 KB
02.txt WA 110 ms 14080 KB
03.txt WA 112 ms 14080 KB
04.txt WA 111 ms 14080 KB
05.txt WA 110 ms 14080 KB
06.txt WA 268 ms 17664 KB
07.txt WA 312 ms 17536 KB
08.txt WA 287 ms 17152 KB
09.txt WA 305 ms 16768 KB
10.txt WA 271 ms 16768 KB
11.txt WA 261 ms 17664 KB
12.txt WA 304 ms 16768 KB
13.txt WA 327 ms 17024 KB
14.txt WA 308 ms 17536 KB
15.txt WA 260 ms 17408 KB
16.txt WA 281 ms 16896 KB
17.txt WA 288 ms 17536 KB
18.txt WA 273 ms 17664 KB
19.txt WA 243 ms 17408 KB
20.txt WA 283 ms 17152 KB
21.txt AC 355 ms 12928 KB
22.txt WA 335 ms 16896 KB
23.txt WA 282 ms 14080 KB
24.txt WA 132 ms 13824 KB
25.txt WA 128 ms 13952 KB
26.txt AC 124 ms 12928 KB
27.txt AC 87 ms 12928 KB
28.txt AC 92 ms 12928 KB
29.txt AC 91 ms 12928 KB
30.txt WA 91 ms 12928 KB
31.txt AC 12 ms 5760 KB
32.txt AC 74 ms 12160 KB
33.txt AC 11 ms 5760 KB
34.txt WA 82 ms 13440 KB
35.txt WA 11 ms 5760 KB
36.txt WA 11 ms 5760 KB
s1.txt AC 11 ms 5760 KB
s2.txt AC 12 ms 5760 KB