AtCoder B - Pizza

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 200200 points

Problem Statement

We have a circular pizza.
Takahashi will cut this pizza using a sequence AA of length NN, according to the following procedure.

  • First, make a cut from the center in the 1212 o'clock direction.
  • Next, do NN operations. The ii-th operation is as follows.
    • Rotate the pizza A_iAi​ degrees clockwise.
    • Then, make a cut from the center in the 1212 o'clock direction.

For example, if A=(90,180,45,195)A=(90,180,45,195), the procedure cuts the pizza as follows.

Find the center angle of the largest pizza after the procedure.

Constraints

  • All values in input are integers.
  • 1 \le N \le 3591≤N≤359
  • 1 \le A_i \le 3591≤Ai​≤359
  • There will be no multiple cuts at the same position.

Input

Input is given from Standard Input in the following format:

NN
A_1A1​ A_2A2​ \dots… A_NAN​

Output

Print the answer as an integer.


Sample Input 1 Copy

Copy

4
90 180 45 195

Sample Output 1 Copy

Copy

120

This input coincides with the example in the Problem Statement.
The center angle of the largest pizza is 120120 degrees.


Sample Input 2 Copy

Copy

1
1

Sample Output 2 Copy

Copy

359

Sample Input 3 Copy

Copy

10
215 137 320 339 341 41 44 18 241 149

Sample Output 3 Copy

Copy

170

 

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
 
using namespace std;
 
inline int read()
{
	int x = 0, y = 1;
	char c = getchar();
	while(c < '0' || c > '9')
	{
		if(c == '-')  y = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9')
		x = x * 10 + c - '0', c = getchar();
	return x * y;
}
 
typedef unsigned long long LL;

typedef pair<LL, LL> PII;
 
const int N = 1e6 + 10;

int n, q, res, m, cnt, maxm;
bool f[N];


signed main()
{
	n = read();
	f[0] = true;
	for(int i = 1; i <= n; i ++ )
	{
		int x;
		x = read();
		res += x; res %= 360;
		f[res] = true;
	}
	for(int i = 0; i <= 360; i ++ )
	{
		if(f[i % 360])  
		{
			maxm = max(maxm, cnt);
			cnt = 0;
		}
		cnt ++;
	}
	cout << maxm << endl;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值