abbyy cup a
link: http://codeforces.com/contest/331/problem/A2
/*
ID: zypz4571
LANG: C++
TASK: abby_a.cpp
*/ #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <functional>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#include <ctime>
#include <iterator>
const int INF = 0x3f3f3f3f;
const int dir[][] = {{-,},{,},{,-},{,},{-,-},{-,},{,-},{,}};
using namespace std;
long long int a[], sum[];
map<int, int> coll;
int main ( int argc, char *argv[] )
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
ios::sync_with_stdio(false);
int n; cin>>n;
sum[] = ;
for (int i = ; i<= n; ++i) {
cin>>a[i];
sum[i] = sum[i-] + (a[i]>=?a[i]:);
}
int L, R;
long long ans=-(long long)2e18;
for (int i = n; i >= ; --i) {
if (coll.count(a[i]) > ) {
int pos = coll[a[i]];
long long tmp = a[i]*+sum[pos-]-sum[i];
if (tmp > ans) {
ans = tmp;
L = i; R = pos;
}
}
else coll[a[i]] = i;
}
cout<<ans<<' ';
vector<int> coll1;
for (int i = ; i < L; ++i) coll1.push_back(i);
for (int i = L+; i < R; ++i) if (a[i]<) coll1.push_back(i);
for (int i = R+; i <= n; ++i) coll1.push_back(i);
cout<<coll1.size()<<endl;
for (int i = ; i < (int)coll1.size(); ++i) {
cout<<coll1[i];
if (i == (int)coll1.size()-) cout<<endl;
else cout<<' ';
}
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */
care about 10^5*3*10^9=3*10^14. so you should use long long int!
And ans should not be initialized as 0x3f3f3f3f, it is too small!
abbyy cup a的更多相关文章
- codeforce ABBYY Cup 3.0 - Finals (online version) B2. Shave Beaver! 线段树
B2. Shave Beaver! The Smart Beaver has recently designed and built an innovative nanotechnologic a ...
- ABBYY Cup 3.0G3. Good Substrings
题意:定义一个串合法,在n个串中出现次数在li到ri中.问s的所有本质的子串有是多少合法的 题解:把所有串用分隔符分开建sam,记录一个该节点对应每个串的出现次数,topo排序后,当该节点s出现次数不 ...
- ABBYY Cup 3.0 - Finals (online version)
A 开个数组记录一下 #include <iostream> #include<cstdio> #include<cstring> #include<algo ...
- codeforces C1. The Great Julya Calendar 解题报告
题目链接:http://codeforces.com/problemset/problem/331/C1 这是第一次参加codeforces比赛(ABBYY Cup 3.0 - Finals (onl ...
- CodeForces 316c1 Tidying Up
Tidying Up Time Limit: 4000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Orig ...
- java高cup占用解决方案
项目中发现java cpu占用高达百分之四百,查看代码发现有一个线程在空转,拉高了cup while(true){ } 解决方案,循环中加入延迟:Thread.sleep(Time): 总结下排查CP ...
- UVALive 7147 World Cup(数学+贪心)(2014 Asia Shanghai Regional Contest)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...
- ABBYY PDF Transformer+怎么标志注释
ABBYY PDF Transformer+是一款可创建.编辑.添加注释及将PDF文件转换为其他可编辑格式的通用工具,可用来在PDF页面的任何位置添加注释(关于如何通过ABBYY PDF Transf ...
- ABBYY FineReader 12对系统有哪些要求
ABBYY FineReader是市场领先的ocr文字识别软件,可快速方便地将扫描的文档.PDF文档和图像文件(包括数码照片)转化为可编辑.可搜索的格式.每个软件都有其安装运行的系统要求,ABBYY ...
随机推荐
- 设置AFNetworking网络请求的超时时间
http://www.mamicode.com/info-detail-511816.html // 设置超时时间 [manager.requestSerializer willChangeValue ...
- Rhel6-lanmp架构配置文档
l--操作系统:windows linux unix mac OS a--网页发布软件:apache nginx iis m--数据库:mysql pgsql oracle... p--网页 ...
- “System.Threading.ThreadAbortException”类型的第一次机会异常在 mscorlib.dll 中发
问题原因: Thread.Abort 方法 .NET Framework 4 其他版本 1(共 1)对本文的评价是有帮助 - 评价此主题 在调用此方法的线程上引发 ThreadAbortExce ...
- hashmap and hashtable
①继承不同. public class Hashtable extends Dictionary implements Map public class HashMap extends Abstrac ...
- BinaryWriter
c#里的文件操作 fileInfo dir的一大堆属性不用说 地球人都知道(什么fileName,create() delete()) ,文件系统的概念很好理解的 文件读写也好理解(硬盘到内存 然后再 ...
- Windows Azure 实操 —— 迁移本地SharePoint服务器到Azure
博客地址 http://blog.csdn.net/foxdave 注意:如果你是第二代虚拟机,那就别看这个了,老老实实在Azure上重新创建吧,Azure不支持第二代虚拟机. 写在之前,对Azure ...
- SharePoint 2013 Nintex Workflow 工作流帮助(八)
博客地址 http://blog.csdn.net/foxdave 工作流动作 15. Complete Workflow Task(User interaction分组) 此工作流动作将完成任何进行 ...
- (转)UIApplication sharedApplication详细解释-IOS
iPhone应用程序是由主函数main启动,它负责调用UIApplicationMain函数,该函数的形式如下所示: int UIApplicationMain ( int argc, char *a ...
- HashMap简单理解
1. hashmap基于哈希表的map接口实现,此实现提供所有可选的映射操作,并允许使用 null 值和 null 键.(除了非同步和允许使用 null 之外,HashMap 类与 Hashtable ...
- ACM -二分图题目小结
暂时只包括与最大匹配相关的问题. 求最大独立集,最小路径覆盖等等大多数题目都可以转化为求最大匹配用匈牙利算法解决. 1.最大匹配(边集) 此类问题最直接,直接用匈牙利算法即可. HDU 2063 过 ...