当前位置:网站首页>AtCoder B - Pizza
AtCoder B - Pizza
2022-07-23 19:58:00 【MITBlick】
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;
}边栏推荐
- Energy principle and variational method note 12: minimum potential energy principle
- [PM2] PM2 common commands
- Energy principle and variational method note 15: solution of differential element method
- 能量原理与变分法笔记16:虚位移原理的求解
- White paper on adaptive robot interaction
- Element positioning in selenium is correct, but the operation fails. Six solutions are all finalized
- C language leak detection and filling (1)
- Whether the R language test sample conforms to normality (whether the test sample is from a normally distributed population): SF of nortest package is used The test function verifies whether the sampl
- What if redis breaks down?
- 【面试:并发篇22多线程:ReentrantLock】
猜你喜欢

The numerical sequence caused by the PostgreSQL sequence cache parameter is discontinuous with interval gap

Cannot read properties of null (reading ‘pickAlgorithm‘)

selenium中元素定位正确但是操作失败,6种解决办法全稿定
![[激光器原理与应用-8]: 激光器电路的电磁兼容性EMC设计](/img/98/8b7a4fc3f9ef9b7e16c63a8c225b02.png)
[激光器原理与应用-8]: 激光器电路的电磁兼容性EMC设计

Powercli imports licensekey to esxi

能量原理与变分法笔记12:最小势能原理

Powercli add esxi host to vCenter

重装系统后故障(报错:reboot and select proper boot deviceor insert boot media in selected boot device)
![[hero planet July training leetcode problem solving daily] 23rd dictionary tree](/img/e3/74cb4ce8aa08e0ea90e26bb2d197c3.png)
[hero planet July training leetcode problem solving daily] 23rd dictionary tree

Educational Codeforces Round 132 (Rated for Div. 2)【比赛记录】
随机推荐
【AR学习】-- 二、 环境搭建
Compiler llvm MLIR introductions llvm backend instruction
The numerical sequence caused by the PostgreSQL sequence cache parameter is discontinuous with interval gap
[interview: concurrent Article 22 multithreading: reentrantlock]
Redis坏了怎么办?
搭建自己的目标检测环境,模型配置,数据配置 MMdetection
AtCoder Regular Contest 144【VP记录】
Redux求和案例详解版教程
Latex (KAtex) CSDN Greek alphabet representation, mathematical symbols, set symbols, special marks
MySQL 数据恢复 —— 使用 data 目录
Eight common SQL misuses in MySQL
Decryption: PTP clock synchronization in intelligent substation (Beidou clock server)
能量原理与变分法笔记18:虚力原理
Energy principle and variational method note 16: solution of virtual displacement principle
Attack and defense world web question Fakebook
Leetcode 228. 汇总区间(可以,已解决)
PC performance monitoring tool is an indispensable helper for software testers
重装系统后故障(报错:reboot and select proper boot deviceor insert boot media in selected boot device)
osgearth2.8编译siverlining云效果
PC性能监测工具,软件测试人员不可或缺的好帮手