武大校赛资格赛 差值维护
来源:互联网 发布:mysql可以不要主键吗 编辑:程序博客网 时间:2024/06/10 03:02
Problem 1565 - B - Magic
Description
Here are n numbers.
You have a magic : first , you choose a interval [l,r],and then each Si(l<=i<=r) will be ( 10 – Si ) % 10.
You can use the magic at most once to make sum of all the numbers to be maximum.
What is the maximum sum you can get?
Input
First line of each case contains a number n.(1 ≤ n ≤ 1 000 000).
Next line contains n numbers without space-separated. Each position corresponds to a number of 0-9.
Next line contains n numbers without space-separated. Each position corresponds to a number of 0-9.
Output
Output the answer on a single line for each case.
Sample Input
10
3775053808
10
2580294019
10
4701956095
3775053808
10
2580294019
10
4701956095
Sample Output
50
50
54
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#include <string>#include <vector>#include <set>#include <map>#include <stack>#include <queue>#include <sstream>#include <iomanip>using namespace std;typedef long long LL;const int INF = 0x4fffffff;const double EXP = 1e-5;const int MS = 1000005;const int SIZE = 100005;int num[MS];int s[MS];char str[MS];int main(){ int n; while(cin>>n) { // cin>>n; cin>>str; int sum=0; int ans=0; int total=0; // s[0]=0; // int ss,tt; for(int i=0;i<n;i++) { //num[i]=10-(2*(str[i]-'0')); num[i]=(10-(str[i]-'0'))%10; num[i]=num[i]-(str[i]-'0'); // s[i+1]=s[i]+str[i]-'0'; total+=str[i]-'0'; if(sum<=0) { sum=num[i]; //ss=i; } else sum+=num[i]; if(sum>ans) { ans=sum; // tt=i; } } // cout<<ans<<endl; //cout<<ss<<" "<<tt<<endl; cout<<total+ans<<endl; } return 0;}
0 0
- 武大校赛资格赛 差值维护
- 武大校赛资格赛 最小矩阵覆盖
- 武大校赛资格赛 求方差
- 2015武大校赛
- 武大校赛感想
- Problem 1581 - Union of cubes+武大校赛+线段树维护
- 差值维护
- 武大校赛E题
- qbxt 差值维护
- 武大校赛网络赛B题
- 武大校赛网络赛总结
- 川大校赛总结
- 郑大校赛总结
- 河工大校赛终结
- 河工大校赛总结
- 河工大校赛
- 2017 上大校赛
- WOJ 武大校赛 Problem 1537 - A - Stones I
- spring的annotation-driven配置事务管理器详解
- j2ee--网络编程
- JavaScript函数(未完)
- 成都信用卡套现代还18200360025
- 【通知】新浪微博搜索
- 武大校赛资格赛 差值维护
- IOException while loading persisted sessions: java.io.EOFException异常的解决办法
- cocos2dx笔记--hellolua 示例
- 1002. 写出这个数
- 2015第一季度个人总结及下季度计划
- 简述互联网背景下的金融和支付
- web弹层不懈的追求者,layer1.9.0正式版虔诚发布
- Matlab find函数的用法
- AlertDialog三种对话框的实现