Submission #206142

# Submission time Handle Problem Language Result Execution time Memory
206142 2020-03-02T12:15:11 Z aloo123 Prosjek (COCI14_prosjek) C++14
50 / 50
5 ms 376 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
using namespace std;

const ll N = 2e5+5;
const ll MOD = 1e9+7;
int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	ll n;
	cin >> n;
	ll a[n+1];
	for(int i =1;i<=n;i++) cin >> a[i];
	ll b[n+1];
	b[1] = a[1];

	ll sum = b[1];
	for(int i =2;i<=n;i++){
		// (sum + x)/i = a[i]
		// sum + x = a[i] * i
		// x = a[i] * i -sum
		b[i] = (a[i] * i) - sum;
		sum += b[i];
	}
	
	for(int i=1;i<=n;i++) cout<<b[i]<<" ";cout<<endl;
}

Compilation message

prosjek.cpp: In function 'int main()':
prosjek.cpp:36:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int i=1;i<=n;i++) cout<<b[i]<<" ";cout<<endl;
  ^~~
prosjek.cpp:36:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int i=1;i<=n;i++) cout<<b[i]<<" ";cout<<endl;
                                        ^~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct