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的更多相关文章

  1. 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 ...

  2. ABBYY Cup 3.0G3. Good Substrings

    题意:定义一个串合法,在n个串中出现次数在li到ri中.问s的所有本质的子串有是多少合法的 题解:把所有串用分隔符分开建sam,记录一个该节点对应每个串的出现次数,topo排序后,当该节点s出现次数不 ...

  3. ABBYY Cup 3.0 - Finals (online version)

    A 开个数组记录一下 #include <iostream> #include<cstdio> #include<cstring> #include<algo ...

  4. codeforces C1. The Great Julya Calendar 解题报告

    题目链接:http://codeforces.com/problemset/problem/331/C1 这是第一次参加codeforces比赛(ABBYY Cup 3.0 - Finals (onl ...

  5. CodeForces 316c1 Tidying Up

    Tidying Up Time Limit: 4000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Orig ...

  6. java高cup占用解决方案

    项目中发现java cpu占用高达百分之四百,查看代码发现有一个线程在空转,拉高了cup while(true){ } 解决方案,循环中加入延迟:Thread.sleep(Time): 总结下排查CP ...

  7. UVALive 7147 World Cup(数学+贪心)(2014 Asia Shanghai Regional Contest)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...

  8. ABBYY PDF Transformer+怎么标志注释

    ABBYY PDF Transformer+是一款可创建.编辑.添加注释及将PDF文件转换为其他可编辑格式的通用工具,可用来在PDF页面的任何位置添加注释(关于如何通过ABBYY PDF Transf ...

  9. ABBYY FineReader 12对系统有哪些要求

    ABBYY FineReader是市场领先的ocr文字识别软件,可快速方便地将扫描的文档.PDF文档和图像文件(包括数码照片)转化为可编辑.可搜索的格式.每个软件都有其安装运行的系统要求,ABBYY ...

随机推荐

  1. uboot启动 及命令分析(3)

    u-boot命令 先贴一个重要结构,位于uboot/include/command.h,这个结构代表每个uboot命令 struct cmd_tbl_s { char     *name;   /* ...

  2. 【第53套模拟题】【递推】【RMQ】【二进制】【分块】

    题目:(开始自己描述题目了...) 第一题大意: 求1~n的所有排列中逆序对为k个的方案数,输出方案数%10000,n<=1000. 解:这道题一个递推,因为我基本上没怎么自己做过递推,所以推了 ...

  3. 神奇的NOIP模拟赛 T3 LGTB 玩THD

    LGTB 玩THD LGTB 最近在玩一个类似DOTA 的游戏名叫THD有一天他在守一座塔,对面的N 个小兵排成一列从近到远站在塔前面每个小兵有一定的血量hi,杀死后有一定的金钱gi每一秒,他都可以攻 ...

  4. 使用 JDBC 调用函数 & 存储过程

    /** * 如何使用 JDBC 调用存储在数据库中的函数或存储过程 */ @Test public void testCallableStatment() { Connection connectio ...

  5. C++-什么时候需要在类的构造函数中使用初始化列表

    1,如果基类没有default构造函数,则意味着其不能自己初始化.如果其被派生,派生类的构造函数要负责调用基类的构造函数,并传递给它需要的参数.下例中Base 2,如果类成员没有默认构造函数.下例中E ...

  6. Altium Designer 2013 13 复制出错的问题

    刚换成Altium Designer 2013 13,谁知先碰了钉子,为了赶进度需要复制以前的一个原理图上的部分电路图,一复制尽然报错不能复制,通过百度和向高人求助,总结一下两种方法: 1.在电脑上虚 ...

  7. GoldenGate 之 Bounded Recovery说明

    首先,我们来看两个OGG同步中可能的问题: l oracle在线日志包含已提交的和未提交的事务,但OGG只会将已提交的事务写入到队列文件.因此,针对未提交的事务,特别是未提交的长事务,OGG会怎样处理 ...

  8. poj1014 dp 多重背包

    //Accepted 624 KB 16 ms //dp 背包 多重背包 #include <cstdio> #include <cstring> #include <i ...

  9. Fractal Tree

    尝试使用递归方式实现一棵简单的分形树,给出初始点的坐标,在此基础上根据坐标轴旋转的规则计算出子树干与根节点的坐标关系,依次递归画出左子树干和右子树干,并提供一个递归的深度用于控制画的子树的数目. 在二 ...

  10. 修改主机名Ubuntu

    主机名存放在/etc/hostname 修改保存即可