标签:cal day01 unit reac cstring jin ble ttl ica
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 4467 Accepted Submission(s): 1069
1 //2017-10-08 2 #include <cstdio> 3 #include <iostream> 4 #include <cstring> 5 #include <algorithm> 6 7 using namespace std; 8 9 const int N = 200010; 10 int arr[N], n, m, l, ans, T; 11 12 int main(){ 13 int kase = 0; 14 scanf("%d", &T); 15 while(T--){ 16 scanf("%d%d%d", &n, &m, &l); 17 arr[0] = 0; 18 arr[n+1] = m; 19 for(int i = 1; i <= n; i++) 20 scanf("%d", &arr[i]); 21 sort(arr, arr+n+1); 22 ans = 0; 23 int k = l; 24 for(int i = 1; i <= n+1; i++){ 25 int a = (arr[i]-arr[i-1])%(l+1); 26 int b = (arr[i]-arr[i-1])/(l+1); 27 if(a+k >= l+1){ 28 k = a; 29 ans += 2*b+1; 30 }else{ 31 k += a; 32 ans += 2*b; 33 } 34 } 35 cout<<"Case #"<<++kase<<": "<<ans<<endl; 36 } 37 38 return 0; 39 }
HDU5037(SummerTrainingDay01-C)
标签:cal day01 unit reac cstring jin ble ttl ica
原文地址:http://www.cnblogs.com/Penn000/p/7637370.html