Code666 (代码贴、代码片段)
创建
最近
趋势
关于
[C] ACM题目:吉哥系列故事——临时工计划 →→→→→
进入此内容的聊天室
来自 , 2021-01-05, 写在 C, 查看 162 次.
URL
http://www.code666.cn/view/d3b1fb02
下载便签
或
查看源码
—
扩张便签
来填满整个浏览器
/*
2013腾讯马拉松初赛第0场
1003吉哥系列故事——临时工计划
Time Limit: 1.0 Seconds Memory Limit: 32768K
俗话说一分钱难倒英雄汉,高中几年下来,吉哥已经深深明白了这个道理,因此,新年开始存储一年的个人资金已经成了习惯,不过自从大学之后他不好意思再向大人要压岁钱了,只能把唯一的希望放到自己身上。可是由于时间段的特殊性和自己能力的因素,只能找到些零零碎碎的工作,吉哥想知道怎么安排自己的假期才能获得最多的工资。
已知吉哥一共有m天的假期,每天的编号从1到m,一共有n份可以做的工作,每份工作都知道起始时间s,终止时间e和对应的工资c,每份工作的起始和终止时间以天为单位(即天数编号),每份工作必须从起始时间做到终止时间才能得到总工资c,且不能存在时间重叠的工作。比如,第1天起始第2天结束的工作不能和第2天起始,第4天结束的工作一起被选定,因为第2天吉哥只能在一个地方工作。
现在,吉哥想知道怎么安排才能在假期的m天内获得最大的工资数(第m+1天吉哥必须返回学校,m天以后起始或终止的工作是不能完成的)。
Input
第一行是数据的组数T;
每组数据的第一行是2个正整数:假期时间m和可做的工作数n;
接下来n行分别有3个正整数描述对应的n个工作的起始时间s,终止时间e,总工资c。
[Technical Specification]
1<=T<=1000
9<m<=100
0<n<=1000
s<=100, e<=100, s<=e
c<=10000
Output
对于每组数据,输出吉哥可获得的最高工资数。
Sample Input
1
10 5
1 5 100
3 10 10
5 10 100
1 4 2
6 12 266
Sample Output
102
*/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
using namespace std
;
vector
<
int
>
s
[
110
]
;
vector
<
int
>
c
[
110
]
;
int
dp
[
110
]
;
int
main
(
)
{
int
T
;
int
m
,
n
;
scanf
(
"%d"
,&
T
)
;
while
(
T
--
)
{
scanf
(
"%d%d"
,&
m
,&
n
)
;
int
x
,
y
,
z
;
for
(
int
i
=
0
;
i
<=
m
;
i
++
)
{
s
[
i
]
.
clear
(
)
;
c
[
i
]
.
clear
(
)
;
dp
[
i
]
=
0
;
}
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
scanf
(
"%d%d%d"
,&
x
,&
y
,&
z
)
;
if
(
x
>
m
||
y
>
m
)
continue
;
if
(
x
>
y
)
continue
;
if
(
x
<
1
)
continue
;
s
[
y
]
.
push_back
(
x
)
;
c
[
y
]
.
push_back
(
z
)
;
}
for
(
int
i
=
1
;
i
<=
m
;
i
++
)
{
dp
[
i
]
=
dp
[
i
-
1
]
;
int
sz
=
s
[
i
]
.
size
(
)
;
for
(
int
j
=
0
;
j
<
sz
;
j
++
)
{
dp
[
i
]
=
max
(
dp
[
i
]
,
dp
[
s
[
i
]
[
j
]
-
1
]
+
c
[
i
]
[
j
]
)
;
}
}
printf
(
"%d
\n
"
,
dp
[
m
]
)
;
}
return
0
;
}
回复 "ACM题目:吉哥系列故事——临时工计划"
这儿你可以回复上面这条便签
作者
你的名字是?
标题
给你的便签一个标题。
语言
你的便签是以
Plain Text
HTML5
CSS
JavaScript
PHP
Python
Ruby
Lua
Bash
Erlang
Go
C
C++
Diff-output
LaTeX
SQL
XML
-----------------
4CS
MOS 6502
MOS 6502 Kick Assembler
MOS 6502 TASM/64TASS
Motorola 68000 Devpac Assembler
ABAP
Actionscript
ActionScript3
Ada
AIMMS
ALGOL 68
Apache
AppleScript
Apt sources.list
ARM Assembler
x86 Assembler
asymptote
ASP
autoconf
Autohotkey
AutoIT
AviSynth
Awk
BASCOM AVR
Basic4GL
BBCode
Brainfuck
BibTeX
BlitzBasic
BNF (Backus-Naur form)
Boo
C (for LoadRunner)
C for Macs
C with WiAPI
CAD DCL (Dialog Control Language)
AutoCAD/IntelliCAD Lisp
CFDG
ColdFusion
ChaiScript
Chapel
CIL (Common Intermediate Language)
Clojure
CMake
COBOL
CoffeeScript
C++ with WinAPI
C#
Cuesheet
D
Dart
DCS
DCL
DCPU/16 Assembly
Delphi (Object Pascal)
DIV
DOS
dot
E
ECMAScript
Eiffel
Email (mbox/eml/RFC format)
Enerscript
Euphoria
EZT
Formula One
Falcon
fo
Fortran
FreeBasic
FreeSWITCH
F#
GAMBAS
GDB
Genero
Genie
GNU Gettext .po/.pot
glSlang
GML
Gnuplot script
Groovy
GwBasic
Haskell
Haxe
HicEst
HQ9+
HTML 4.01 strict
Icon
Unoidl
INI
Inno Script
INTERCAL
Io
ISPF Panel
J
Java
Java 5
Job Control Language
jQuery 1.3
KLone with C
KLone with C++
Kotlin
Liberty BASIC
LDIF
Generic Lisp
LLVM
Locomotive Basic (Amstrad CPC series)
Logcat
Logtalk
LOLcode
@Formula/@Command
LotusScript
Lightwave Script
Linden Scripting
Motorola 68000 Assembler
MagikSF
Make
MapBasic
Matlab M-file
mIRC Scripting
MMIX Assembler
Modula-2
Modula-3
Microchip Assembler
MXML
MySQL
Nagios
NetRexx
newLISP
nginx
Nimrod
Nullsoft Scriptable Install System
Oberon-2
Objective-C
Objeck Programming Language
OCaml (Objective Caml)
GNU Octave M-file
OpenOffice.org Basic
ooRexx
Oracle 11i
Oracle 8
Delphi Prism (Oxygene)
Oz
ParaSail
PARI/GP
Pascal
PCRE
Per (forms)
Perl
Perl 6
OpenBSD packet filter
PIC16 Assembler
Pike
Pixel Bender 1.0
PL/I
Oracle 9.2 PL/SQL
PostgreSQL
Postscript
Povray
PowerBuilder (PowerScript)
PowerShell
ProFTPd
Progress
Prolog
Property
ProvideX
PureBasic
Python for S60
q/kdb+
QBasic/QuickBASIC
QML
Racket
Ruby (with Ruby on Rails Framework)
RBS Script
Rebol
Microsoft Registry Editor
Rexx
robots.txt
RPM Spec
R
Rust
SAS
Scala
Scheme
SciLab
SCL
sdlBasic
Smalltalk
Smarty template
SPARK
SPARQL
StandardML
StoneScript
SystemVerilog IEEE 1800-2009(draft8)
TCL/iTCL
Tera Term Macro
thinBasic
T-SQL
TypoScript
Unicon
UnrealScript
UPC
Urbi
Vala
Visual Basic
VB.NET
VBScript
Vedit macro language
Verilog
VHDL
Vim scripting
Visual FoxPro
Visual Prolog
Whitespace
Whois response (RPSL format)
WinBatch
XBasic
xorg.conf
Axapta/Dynamics Ax X++
YAML
ZiLOG Z80 Assembler
ZXBasic
你的便签
在这儿输入便签内容
/* 2013腾讯马拉松初赛第0场 1003吉哥系列故事——临时工计划 Time Limit: 1.0 Seconds Memory Limit: 32768K 俗话说一分钱难倒英雄汉,高中几年下来,吉哥已经深深明白了这个道理,因此,新年开始存储一年的个人资金已经成了习惯,不过自从大学之后他不好意思再向大人要压岁钱了,只能把唯一的希望放到自己身上。可是由于时间段的特殊性和自己能力的因素,只能找到些零零碎碎的工作,吉哥想知道怎么安排自己的假期才能获得最多的工资。 已知吉哥一共有m天的假期,每天的编号从1到m,一共有n份可以做的工作,每份工作都知道起始时间s,终止时间e和对应的工资c,每份工作的起始和终止时间以天为单位(即天数编号),每份工作必须从起始时间做到终止时间才能得到总工资c,且不能存在时间重叠的工作。比如,第1天起始第2天结束的工作不能和第2天起始,第4天结束的工作一起被选定,因为第2天吉哥只能在一个地方工作。 现在,吉哥想知道怎么安排才能在假期的m天内获得最大的工资数(第m+1天吉哥必须返回学校,m天以后起始或终止的工作是不能完成的)。 Input 第一行是数据的组数T; 每组数据的第一行是2个正整数:假期时间m和可做的工作数n; 接下来n行分别有3个正整数描述对应的n个工作的起始时间s,终止时间e,总工资c。 [Technical Specification] 1<=T<=1000 9
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std; vector
s[110]; vector
c[110]; int dp[110]; int main() { int T; int m,n; scanf("%d",&T); while(T--) { scanf("%d%d",&m,&n); int x,y,z; for(int i=0;i<=m;i++) { s[i].clear(); c[i].clear(); dp[i]=0; } for(int i=0;i
m||y>m)continue; if(x>y)continue; if(x<1)continue; s[y].push_back(x); c[y].push_back(z); } for(int i=1;i<=m;i++) { dp[i]=dp[i-1]; int sz=s[i].size(); for(int j=0;j
创建短链接
创建一个较短的URL,连接到这个便签
私人
私人便签不会显示在最近列表中
保存期限
我们应该什么时候删除这张便签?
阅后即焚
五分钟
一小时
一天
一周
一月
一年
永久保留
防滥用
键入这些字符
创建