当前位置:网站首页>AtCoder B - Pizza
AtCoder B - Pizza
2022-07-23 18:29: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;
}边栏推荐
猜你喜欢

攻防世界web题-fakebook

能量原理与变分法笔记14:总结+问题的求解

梅科尔工作室-华为14天鸿蒙设备开发实战笔记六

PostgreSQL sequence cache 参数导致的数值序列不连续 有间隔 gap
![[英雄星球七月集训LeetCode解题日报] 第23日 字典树](/img/e3/74cb4ce8aa08e0ea90e26bb2d197c3.png)
[英雄星球七月集训LeetCode解题日报] 第23日 字典树
![[interview: concurrent Article 22 multithreading: reentrantlock]](/img/a7/19f947faba18e58b768588af414aeb.png)
[interview: concurrent Article 22 multithreading: reentrantlock]

PowerCLi 管理VMware vCenter 一键批量部署OVF

Element positioning in selenium is correct, but the operation fails. Six solutions are all finalized
![Educational codeforces round 132 (rated for Div. 2) [competition record]](/img/7d/ef0df3e0d772b17264beb9c189a3c2.png)
Educational codeforces round 132 (rated for Div. 2) [competition record]

Codeforces Round #805-#808【部分题解】
随机推荐
[深入研究4G/5G/6G专题-40]: URLLC-11-《3GPP URLLC相关协议、规范、技术原理深度解读》-5-5G Qos原理与架构: 切片、PDU会话、QosFlow、5QI、DRB
USB3.0: layout guide for vl817q7-c0
Calculation of structure size (structure memory alignment)
R语言使用dwilcox函数生成Wilcoxon秩和统计分布密度函数数据、使用plot函数可视化Wilcoxon秩和统计分布密度函数数据
Four rotor aircraft 1 - structure and control principle
Type-C Bluetooth speaker single C-Port rechargeable OTG solution
PowerCLi 管理VMware vCenter 一键批量部署OVF
Powercli management VMware vCenter one click batch deployment OVA
《自适应机器人交互白皮书》
【面试:并发篇22多线程:ReentrantLock】
Robot decision-making system based on self-learning (daki technology, Zhao kaiyong)
idea 选中代码生成方法
重装系统后故障(报错:reboot and select proper boot deviceor insert boot media in selected boot device)
三维点云课程(六)——三维目标检测
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
Compiler llvm MLIR introductions llvm backend instruction
[interview: concurrent Article 22 multithreading: reentrantlock]
Educational Codeforces Round 132 (Rated for Div. 2)【比赛记录】
李鸿章 临终诗 临终奏折 全文
Leetcode 216. 组合总和 III