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. 启动 nginx 失败 "fastcgi_pass" directive is duplicate

    [emerg] 4953#0: "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default: ...

  2. SpinEdit

    用code给value赋值会触发 change事件

  3. 单例模式简单解析--Singleton 单例模式(懒汉方式和饿汉方式)

    单例模式的概念: 单例模式的意思就是只有一个实例.单例模式确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例.这个类称为单例类. 关键点: 1)一个类只有一个实例       这是最基本 ...

  4. HDU 3333 - Turing Tree (树状数组+离线处理+哈希+贪心)

    题意:给一个数组,每次查询输出区间内不重复数字的和. 这是3xian教主的题. 用前缀和的思想可以轻易求得区间的和,但是对于重复数字这点很难处理.在线很难下手,考虑离线处理. 将所有查询区间从右端点由 ...

  5. hdu 2035

    Ps:查了下快速幂,顺便在这用下.... 积的求余等于两个数的求余的积再求余... 代码: #include "stdio.h"int mod(int a,int b);int m ...

  6. FR #1题解

    A. 建图跑最小费用最大流.分类讨论每种情况如何连边,费用怎么定. #include<iostream> #include<cstdio> #include<cstrin ...

  7. Inno_setup制作升级包必须面临的几个问题

    Inno_setup制作升级包必须面临的几个问题 分类: c/c++/GamingAnyWhere JavaScript linux shell基础知识 2013-12-18 22:14 1496人阅 ...

  8. WPF Step By Step 自定义模板

    WPF Step By Step 自定义模板 回顾 上一篇,我们简单介绍了几个基本的控件,本节我们将讲解每个控件的样式的自定义和数据模板的自定义,我们会结合项目中的具体的要求和场景来分析,给出我们实现 ...

  9. The name 'Scripts' does not exist in the current context error in MVC

    创建完成ASP.NET MVC4应用程序以后,试着运行其中一个Create页面, 程序报出运行是错误: CS0103: The name 'Scripts' does not exist in  th ...

  10. I.MX6 console 跳过 login

    /*************************************************************************** * I.MX6 console 跳过 logi ...