link:http://acm.sgu.ru/problem.php?contest=0&problem=259

思路就是贪心.

首先要读懂题目,输入的方式,把样例读懂.

第一,打印的总时间一定.需要做的就是送出的时间尽可能的重合,这样总时间就会更少.所以,送出时间长的要尽可能的先打印,按照送出时间从大到小排序就可以了.

 /*
* =====================================================================================
* Filename: 259.cpp
* Created: 06/08/2013 10:15:09
* Author: liuxueyang (lxy), 1459917536@qq.com
* Organization: Hunan University
*
* =====================================================================================
*/ /*
ID: zypz4571
LANG: C++
TASK: 259.cpp
*/
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <list>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define LL long long
const double eps=1e-;
using namespace std;
struct Node{
int t, l;
bool operator < (const Node other) const {
if (l!=other.l) return l>other.l;
else return t<other.t;
}
}a[];
int main ( int argc, char *argv[] )
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
ios::sync_with_stdio(false);
int n;
while (cin>>n) {
for (int i = ; i < n; ++i) cin>>a[i].t;
for (int i = ; i < n; ++i) cin>>a[i].l;
int ans=, sum=;
sort(a,a+n);
for (int i = ; i < n; ++i) {
sum += a[i].t;
ans = max(ans, sum+a[i].l);
}
cout<<ans<<endl;
}
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */

开始要读懂题目意思啊,读题认真.

sgu259 Printed PR    贪心的更多相关文章

  1. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  2. uva.10020 Minimal coverage(贪心)

    10020 Given several segments of line (int the X axis) with coordinates [Li, Ri]. You are to choose t ...

  3. [2012山东ACM省赛] Pick apples (贪心,完全背包,枚举)

    Pick apples Time Limit: 1000MS Memory limit: 165536K 题目描述 Once ago, there is a mystery yard which on ...

  4. POJ 1456 Supermarket 区间问题并查集||贪心

    F - Supermarket Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Sub ...

  5. Codeforces Round #342 (Div. 2) B. War of the Corporations 贪心

    B. War of the Corporations 题目连接: http://www.codeforces.com/contest/625/problem/B Description A long ...

  6. UVa 10020 - Minimal coverage(区间覆盖并贪心)

    Given several segments of line (int the X axis) with coordinates [Li, Ri]. You are to choose the min ...

  7. codeforces 335A Banana(贪心)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud    Banana Piegirl is buying stickers for ...

  8. UVA 10020 Minimal coverage(贪心 + 区间覆盖问题)

     Minimal coverage  The Problem Given several segments of line (int the X axis) with coordinates [Li, ...

  9. LOJ 3059 「HNOI2019」序列——贪心与前后缀的思路+线段树上二分

    题目:https://loj.ac/problem/3059 一段 A 选一个 B 的话, B 是这段 A 的平均值.因为 \( \sum (A_i-B)^2 = \sum A_i^2 - 2*B \ ...

随机推荐

  1. MongoDB常用操作一查询find方法db.collection_name.find()

    来:http://blog.csdn.net/wangli61289/article/details/40623097 https://docs.mongodb.org/manual/referenc ...

  2. vim配置及插件安装管理(超级详细)

    1 写在前面   Linux下编程一直被诟病的一点是: 没有一个好用的IDE, 但是听说Linux牛人, 黑客之类的也都不用IDE. 但是对我等从Windows平台转移过来的Coder来说, 一个好用 ...

  3. SharePoint开发 - 使用Session(代码修改webconfig)

    博客地址 http://blog.csdn.net/foxdave SharePoint启用Session可以使用Powershell,戳这里:可以修改webconfig. 本篇叙述的重点是通过fea ...

  4. IntelliJ IDEA 12.0

    User name:JavaDeveloper Serial number:92547-KY2BB-QZ0S1-PEZCV-HUT8Q-6RYY4

  5. 关于 IOS 发布的点点滴滴记录(一)

    今天又是发布 APP 审核的时候,哎,说来也悲催. 我们产品连这次好像是第四次被苹果公司拒绝了,想想都有点伤感.其实对于里面的内容我到是不是很关心.我关心的是在这过程中我所碰到的奇怪的事情.  (这次 ...

  6. zoj1610 线段树

    //Accepted 804 KB 40 ms //整个题,都是坑 //1.The first line of each data set contains exactly one integer n ...

  7. PIT,BL,AP,CP,CSC

    使用ODIN刷机的时候,要选择ROM文件,以下是5件套各部分的说明: PIT:分区信息,如果没有更换ROM,一般不需要刷,也不需要勾选re-partition选项 BL:bootloader,引导信息 ...

  8. 爬虫再探之mysql简单使用

    在爬取数据量比较大时,用EXCEL存取就不太方便了,这里简单介绍一下python操作mysql数据库的一些操作.本人也是借助别人的博客学习的这些,但是找不到原来博客链接了,就把自己的笔记写在这里,这里 ...

  9. AD管理命令

    repadmin /showrepl   显示复制协议 dcdiag /test:dns

  10. 清除浮动1-使用:after 伪元素

    <!doctype html><html> <head> <meta charset="UTF-8"> <meta name= ...