标签:open fine algo close scan i++ 思路 style type
1059A---Cashier
题意:
Vasya每天工作\(l\)个小时,每天服务\(n\)个顾客,每个休息时长是\(a\)。给定\(n\)个客人来的时间和时长。问Vasya可以休息多长时间。
思路:
先给客人排个序,然后各个间隔除以休息时间之和就是答案。
1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 #include<cstdlib> 5 #include<cstring> 6 #include<algorithm> 7 #include<queue> 8 #include<vector> 9 #include<set> 10 using namespace std; 11 typedef long long LL; 12 #define N 100010 13 #define pi 3.1415926535 14 15 int n, l, a; 16 const int maxn = 1e5 + 5; 17 struct node{ 18 int l, len; 19 }peo[maxn]; 20 bool cmp(node a, node b) 21 { 22 return a.l < b.l; 23 } 24 25 int main() 26 { 27 while(scanf("%d%d%d", &n, &l, &a) != EOF){ 28 for(int i = 0; i < n; i++){ 29 scanf("%d%d", &peo[i].l, &peo[i].len); 30 } 31 sort(peo, peo + n, cmp); 32 33 int cnt = peo[0].l / a; 34 for(int i = 1; i < n; i++){ 35 cnt += (peo[i].l - peo[i - 1].l - peo[i - 1].len) / a; 36 } 37 cnt += (l - peo[n - 1].l - peo[n - 1].len) / a; 38 printf("%d\n", cnt); 39 40 } 41 return 0; 42 }
1059B---Forgery
题意:
思路:
标签:open fine algo close scan i++ 思路 style type
原文地址:https://www.cnblogs.com/wyboooo/p/9959947.html