zoukankan      html  css  js  c++  java
  • CodeForces 732B Cormen — The Best Friend Of a Man

    //这题也是水题
    
    #include <bits/stdc++.h>
    using namespace std;
    const int N = 505;
    int planned[N];
    int total[N];
    
    int main()
    {
    	int n, k;
    	while (cin >> n >> k)
    	{
    		int ans = 0; // sum of additional hours
    		for (int i = 0; i < n; i++)
    		{
    			cin >> planned[i];
    			total[i] = planned[i];
    		}
    		
    		for (int i = 0; i < (n - 1); i++)
    		{
    			int sum = total[i] + total[i + 1], temp;
    			if (k > sum)
    			{
    				temp = k - sum; ans += temp; total[i + 1] += temp;
    			}
    		}
    		
    		cout << ans << endl;
    		for(int i = 0; i < (n - 1); i++)
    		cout << total[i] << " ";
    		cout << total[n -1] << endl; 
    	}
    	return 0;
    } 

  • 相关阅读:
    jPlayer
    nodemon
    微信
    防盗链
    ES2015 (ES6)
    静态资源
    WebP
    Retina
    ui-grid
    React入门2
  • 原文地址:https://www.cnblogs.com/mofushaohua/p/7789449.html
Copyright © 2011-2022 走看看