Kattis downtime

链接:https://open.kattis.com/problems/downtime

题意:n个要解决的进程,每个服务器可以解决k个进程,每个进程花费1000MS,给出n个进程的开始时间,问最少要几个服务器

思路:我们可以求出每个进程的区间,然后看我们可以不重叠的解决多少个进程

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3
 4 struct node{
 5     int x;
 6     int y;
 7 }a[200005];
 8 bool cmp(node p,node q){
 9     if(p.x==q.x) return p.y<q.y;
10     return p.x<q.x;
11 }
12 int main(){
13     int n,k;
14     scanf("%d%d",&n,&k);
15     int x,l=0;
16     for(int i=1;i<=n;i++){
17         scanf("%d",&x);
18         a[++l].x=x; a[l].y=1;
19         a[++l].x=x+1000;a[l].y=-1;
20     }
21     sort(a+1,a+1+l,cmp);
22     int Max=0,sum=0;;
23     for(int i=1;i<=l;i++){
24       // cout<<a[i].x<<" "<<a[i].y<<endl
25         if(a[i].y==-1) {
26             sum--;
27         }
28         else sum++;
29         Max=max(Max,sum);
30     }
31     if(Max%k!=0) Max=Max/k+1;
32     else Max=Max/k;
33     cout<<Max<<endl;
34     return 0;
35 }
时间: 2024-08-27 01:10:36

Kattis downtime的相关文章

Kattis - Association for Computing Machinery

Association for Computing Machinery ACM (Association for Computing Machinery) organizes the International Collegiate Programming Contest (ICPC) worldwide every year. In the ICPC, a team of three students is presented with a problem set that contains 

Transport Tablespaces with Reduced Downtime using Cross Platform Incremental Backup

OVERVIEW 1 目的 传统的传输表空间方式要求数据第一次由远端到目标端传输时,表空间必须置于read only模式,从而生产不可用.而XTTS方式则只需要在最后一次增量备份时将表空间置于read only模式,显著的减少了停机的时间 XTTS can significantly reduce the amount of downtime required to move data between platforms using enhanced RMAN's bility 2 oracle

Zero Downtime Upgrade of Oracle 10g to Oracle 11g Using GoldenGate — 2

Prepare 10g Database for OGG Create GGS and GGS_MON Database Users SQL> create tablespace ggs_tbs datafile '/u01/app/oracle/oradata/zwc/gg_tbs01.dbf' size 100M; Tablespace created. SQL> create user ggs identified by ggs default tablespace ggs_tbs te

Zero Downtime Upgrade of Oracle 10g to Oracle 11g Using GoldenGate — 3

DDL Setup Steps SQL> grant execute on utl_file to ggs; Grant succeeded. Create GLOBALS file [[email protected] ~]$ cd /ggs/ [[email protected] ggs]$ cat GLOBALS GGSCHEMA GGS run marker_setup.sql [[email protected] ggs]$ sqlplus / as sysdba SQL*Plus:

City Destruction Kattis - city dp

/** 题目:City Destruction Kattis - city 链接:https://vjudge.net/problem/Kattis-city 题意:有n个怪兽,排成一行.每个怪兽有一个生命值和一个爆炸值.每次可以选择一个怪兽攻击早造成d伤害. 如果生命值<=0:那么怪兽i死亡并且爆炸.i+1,i-1第怪兽都会受到 第i个怪兽的爆炸值伤害.如果第i-1被第i炸死,第i-1怪兽不会继续炸别人. 不会传递.也就是只有攻击者攻击致死的怪兽才会对i-1,i+1造成爆炸值伤害. 求最少攻击

Zero Downtime Upgrade of Oracle 10g to Oracle 11g Using GoldenGate — 4

Target Side Setup Install OGG on Target Side Creates required directories for OGG [[email protected] ggs]$ ./ggsci Oracle GoldenGate Command Interpreter for Oracle Version 11.2.1.0.23 18709404 OGGCORE_11.2.1.0.0OGGBP_PLATFORMS_140523.1046_FBO Linux,

Freedom DownTime

Storyline Computer hackers are being portrayed as the newest brand of terrorists. This is a story of a hacker named Kevin Mitnick, imprisoned without bail for nearly five years. Freedom Downtime tries to uncover the reasons why the authorities are so

True Zero Downtime HAProxy Reloads--转载

原文地址:http://engineeringblog.yelp.com/2015/04/true-zero-downtime-haproxy-reloads.html HAProxy: Cornerstone of Reliable Websites One primary goal of the infrastructure teams here at Yelp is to get as close to zero downtime as possible. This means that

Installing Apps Kattis - installingapps (贪心 + 背包)

Installing Apps Kattis - installingapps Sandra recently bought her first smart phone. One of her friends suggested a long list of applications (more commonly known as “apps”) that she should install on the phone. Sandra immediately started installing