比賽總結
打得有點慫,這次div1題目比較水,我做了三題,不過比較坑的是,我第二題因爲少了幾個特判,wa了8次才ac,第三題因爲看錯題,wa了兩次才ac
在正式和非正式選手裏排名438名
在正式選手裏排名306名
(做了三題,罰時太慘被一堆做2題的艹了。。。)
A. Exams
題目鏈接
http://codeforces.com/contest/480/problem/A
題目大意
某人要參加
思路
考試進行的順序,一定是按照
但是每場考試是選
代碼
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#define MAXN 6000
using namespace std;
pair<int,int>pr[MAXN];
int n;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&pr[i].first,&pr[i].second);
sort(pr+1,pr+n+1);
int last=pr[1].second;
for(int i=2;i<=n;i++)
{
if(pr[i].second>=last) last=pr[i].second;
else last=pr[i].first;
}
printf("%d\n",last);
return 0;
}
B. Long Jumps
題目鏈接
http://codeforces.com/contest/480/problem/B
題目大意
給你一個長度爲
思路
顯然,答案最多爲2,如果已經存在了某兩個刻度之間距離爲
這個可以通過枚舉刻度
但是重點不在於此,而是一個特殊情況:有可能存在某兩個已經存在的刻度,插入一個新的刻度後,就可以滿足題目要求了。這個就需要特判了,具體看代碼比較清楚吧
代碼
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#define MAXN 6000
using namespace std;
pair<int,int>pr[MAXN];
int n;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&pr[i].first,&pr[i].second);
sort(pr+1,pr+n+1);
int last=pr[1].second;
for(int i=2;i<=n;i++)
{
if(pr[i].second>=last) last=pr[i].second;
else last=pr[i].first;
}
printf("%d\n",last);
return 0;
}
C. Riding in a Lift
題目鏈接
http://codeforces.com/contest/480/problem/C
題目大意
一個
思路
一個非常顯然的DP思路:
設
這樣DP的複雜度爲
我們知道,給一個序列不斷進行區間加的操作,可以維護一個數組a[]
代碼
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#define MAXN 6000
using namespace std;
pair<int,int>pr[MAXN];
int n;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&pr[i].first,&pr[i].second);
sort(pr+1,pr+n+1);
int last=pr[1].second;
for(int i=2;i<=n;i++)
{
if(pr[i].second>=last) last=pr[i].second;
else last=pr[i].first;
}
printf("%d\n",last);
return 0;
}