1. 程式人生 > >訓練賽-簽到題1

訓練賽-簽到題1

題目連結:https://vjudge.net/contest/260134#problem/A
題目:Vasya has recently got a job as a cashier at a local store. His day at work is LL minutes long. Vasya has already memorized nn regular customers, the ii-th of which comes after titi minutes after the beginning of the day, and his service consumes lili minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer.

Vasya is a bit lazy, so he likes taking smoke breaks for aa minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?

Input
The first line contains three integers nn, LL and aa (0≤n≤1050≤n≤105, 1≤L≤1091≤L≤109, 1≤a≤L1≤a≤L).

The ii-th of the next nn lines contains two integers titi and lili (0≤ti≤L−10≤ti≤L−1, 1≤li≤L1≤li≤L). It is guaranteed that ti+li≤ti+1ti+li≤ti+1 and tn+ln≤Ltn+ln≤L.

Output
Output one integer — the maximum number of breaks.

Examples
Input
2 11 3
0 1
1 1
Output
3
Input
0 5 2
Output
2
Input
1 3 2
1 2
Output
0
Note
In the first sample Vasya can take 33 breaks starting after 22, 55 and 88 minutes after the beginning of the day.

In the second sample Vasya can take 22 breaks starting after 00 and 22 minutes after the beginning of the day.

In the third sample Vasya can’t take any breaks.
題目大意:Vasya一共工作L分鐘,抽一根菸要a分鐘,有顧客時不能抽菸,求V他最多能抽幾根菸。
因為ti+li≤ti+1ti+li≤ti+1 所以只需要根據輸入順序計算Vasya有多少空閒時間進行抽菸。
AC程式碼:

#include<cstdio>
using namespace std;
int main(){
    int n,l,a;
    while(scanf("%d%d%d",&n,&l,&a)!=EOF){
        int temp=0,sum=0;
        int t,tt;
        for(int i=0;i<n;i++){
            scanf("%d%d",&t,&tt);
            sum+=(t-temp)/a;
            temp=t+tt;
        }
    sum+=(l-temp)/a;
    printf("%d\n",sum);
    return 0;
    }
}

相關推薦

訓練-簽到1

題目連結:https://vjudge.net/contest/260134#problem/A 題目:Vasya has recently got a job as a cashier at a local store. His day at work is

中石油新生第三次訓練 C進位制轉換(奇葩解)

題目描述 樂樂正在學進位制轉換,但他老是搞不清楚到底自己是否做對,請你編一程式實現兩種不同進位制之間的資料轉換,幫他檢驗。 輸入 共有三行,第一行是一個正整數,表示需要轉換的數的進位制n(2≤n≤16),第二行是一個n進位制數,若n>10則用大寫字母A~F表示數碼10~15

中石油新生第一次訓練 H掃雷

時間限制: 1 Sec 記憶體限制: 128 MB 提交: 187 解決: 32 題目描述 小Q空的時候挺喜歡玩玩電腦遊戲的。自從程式設計技術提高後,他就想,要是自己也能開發出一款遊戲來,那該多好啊!不過,小Q也不著急,先練好基本功再說。Windows中就有一款叫掃雷的小遊戲,挺好玩的,

ECJTU ACM18級隊員寒假訓練 D CodeForces 1033A

front mem 訪問 n) force stdio.h abs queue ron #include<stdio.h>#include<queue>#include<string.h>#include<math.h>usi

HDU-2017 多校訓練1-補

ACM模版 比賽不是特別順利,第一次打多校,感覺還是英語問題很大,雖然編碼水平也很渣……比賽時做了四道,有些心痛了。賽後補補題吧,先將賽中的四道題寫一下,佔佔流量,然後慢慢新增補的題吧! 1001-Add More Zero 描述 題解

ECJTU ACM18級隊員寒假訓練1 D HDU - 2181

set return string.h bool 註意 esp sca amp n-1 #include<stdio.h>#include<string.h>using namespace std; int map[25][4],path[25];

noip模擬 SAC E#1 - 一道中檔 Factorial

因子 格式 nbsp 整數 100% ostream 沒有 說明 出現 題目背景 數據已修改 SOL君(爐石主播)和SOL菌(完美信息教室講師)是好朋友。 題目描述 SOL君很喜歡階乘。而SOL菌很喜歡研究進制。 這一天,SOL君跟SOL菌炫技,隨口算出了n的階乘。 SOL

【LIbreOJ】#6256. 「CodePlus 2017 12 月」可做1

thml 二維 close cst pos opened std hid 都是 【題意】定義一個n階正方形矩陣為“巧妙的”當且僅當:任意選擇其中n個不同行列的數字之和相同。 給定n*m的矩陣,T次詢問以(x,y)為左上角的k階矩陣是否巧妙。n,m<=500,T<

python基礎技巧綜合訓練1

bsp 大小寫 排序 次數 utf-8 isl per 順序 大寫 1,大小寫翻轉 >>> str=‘hello,GhostWU‘ >>> str.swapcase() ‘HELLO,gHOSTwu‘ 2,從一串字符串中,

比賽-暑假訓練1 (26 Jul, 2018)

答案 ace 第一個 emp 通過 for 問題 暑假 移動 A. 密碼 沒有想到題解裏機智的 P2-P1 避免重復計算,我以為是一個類似最長公共子串的 DP,OrzOrzOrz。 設輸入分別為 A, B 兩個字符串。f[i][j] 表示 A 串前 i 位與 B 串前 j

第四階段組隊訓練第六場( 源:UKIEPC2017)

col radi gre network == led build period tro A: Alien Sunset 題目描述 Following tremendous advances in space flight control software and equa

訓練1

題目連結:https://vjudge.net/problem/CodeForces-118A String Task Petya started to attend programming lessons. On the first lesson his task was to w

2018-2019賽季多校聯合新生訓練第三場(2018/12/8)補題解

感慨 得複習回溯和dfs了。。。 A 變形蟲(語法基礎) 程式碼 #include <bits/stdc++.h> using namespace std; map<int,int> num; int main() { ios::sync_with_stdio(0);

訓練1 B

用1,2,…,n表示n個盤子,稱為1號盤,2號盤,…。號數大盤子就大。經典的漢諾塔問 題經常作為一個遞迴的經典例題存在。可能有人並不知道漢諾塔問題的典故。漢諾塔來源於 印度傳說的一個故事,上帝創造世界時作了三根金剛石柱子,在一根柱子上從下往上按大小 順序摞著64片黃金圓盤。上帝命令婆羅門把圓

訓練1 A

One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that

2018-2019賽季多校聯合新生訓練第四場(2018/12/9)補題解

感慨 這次難度有了明顯的上升啊。。。中間一些題也是挺賤的 A 數一數(思維) 實際上根據觀察一個奇數對應一個偶數是一張正反面,那麼給定兩個區間是不是可以直接列舉呢? 解法 ①列舉,如果中間的數有等於偶數的那麼頁數加一 ②輸出,如果第一頁是奇數那麼頁數再加一否則直接輸出 程式碼 #include

2018-2019賽季多校聯合新生訓練第四場題解與補

這一場比賽我是在宿舍裡打的,環境非常的惡劣(噓) 因為舍友一直在說話啥的 不過這也是沒辦法的事,畢竟是週末嘛~ 上來第一題就給我嚇破膽了 ,嚇得我拿了一個本子在那個地方瘋狂計算,把每種情況都寫出來以後才敢開始coding 後來提交發現已經好多人a了這道題,挺不應該的 還有一個要注意的是,千萬

2018-2019賽季多校聯合新生訓練第三場題解和補

本次成績 第44名(銅牌) 雖然都是銅牌,但是這次比上次強多了2333 這次感覺水題比較多啊,但是還是有幾個不會做的,你們懂那種使勁做一道兩道題就是做不出來的感覺嗎!!!簡直要死,這次比賽和上次比賽間隔太短了,可能導致用腦過度了(滑稽)下面開始我們愉快的題解和補題環節吧!(要是我英語演講能這

2018-2019賽季多校聯合新生訓練第二場題解和補

這場比賽還是銅牌…雖然說只是一個銅牌(第66名),但是已經這也是相當努力之後的結果了 要想拉開差距就只能多做題唄 下面開始啦~ 這題我從剛開始看到做到最後結束都沒有做出來… 問題 A: 朋友 題目描述 同學們應該學會多交一些好朋友。朋友關係是相互的,A 是 B 的好朋友,則 B 也是

2018-2019賽季多校聯合新生訓練第一場題解整和補

做這個題用了沒多長時間就a了四道題,然後覺得我可以做出更多的時候突然發現別的都不太會了..到最後才拿到一個銅牌後來聽說這些 都是2011年慈溪的小學奧賽題,瞬間心態崩了...這都大學了做小學題都這麼費勁啊到頭來,看來還得更努力才行啊~!下面開始咯~ 問題 A: 錄取分數線 題目描述