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 ...
随机推荐
- 用PHP的socket实现客户端到服务端的通信
服务端 <?php error_reporting(E_ALL); set_time_limit(0); ob_implicit_flush(); //本地IP $address = 'loca ...
- 获取css style值
var obj=document.getElementById("btn");var currentStyle=null;if(obj.currentStyle){ current ...
- 注册表 ReadBool类型和 ReadInteger 的关系
function TRegistry.ReadBool(const Name: string): Boolean; begin Result := ReadInteger(Name) <> ...
- 关于Tcp,为什么一定要进行三次握手呢?
主要是防止已经失效的请求报文段突然又传送到了服务端而产生的连接的误判. 考虑如下的情况:客户端发送了一个连接请求报文段到服务端,但是在某些网络节点上长时间滞留了,而后客户端又超时重发了一个连接请求报文 ...
- 常见的Web负载均衡方法
用户手动选择 通过在主站首页入口提供不同线路,不同服务器链接的方式,来实现负载均衡.在一些提供下载业务的网站中比较常见,如:华军软件园. DNS轮询 大多域名注册商都支持对同一主机名添加多条A记录,这 ...
- CCNA 6.9
page 201 show ip route Correction(05-4) Basic configuration of R1: enable configure terminal ...
- bjui给出的一个标准应用的首页
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="utf-8&quo ...
- fastboot 刷system.img 提示 sending 'system' (*KB)... FAILED (remote: data too large)
华为G6-C00卡刷提示OEMSBL错误,只能线刷 ,但是官方找不到线刷img镜像,无奈 网上下了个可以线刷的工具套件 流氓ROM . 使用HuaweiUpdateExtractor(工具百度)把官方 ...
- 虚拟机安装Linux系统图文教程
虚拟机安装Linux系统图文教程 | 浏览:523 | 更新:2014-09-16 15:31 1 2 3 4 5 6 7 分步阅读 Linux系统的安装 工具/原料 VMware 9.0 虚拟机 L ...
- 一些需要注意的C知识点
1.数组在作为参数传递到函数时,会退化为一个指针.也就是说,一旦进入函数内部,数组已经变为了一个指针.其实是在参数传递的时候进行了浅拷贝,编译器会声明一个指针指向该数组,在函数内部所有的操作都是对该临 ...