CSES - Harjoituskisa 14.1.2018 - Results
Submission details
Task:Alitaulukot
Sender:ArktinenKarpalo
Submission time:2018-01-14 19:17:52 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#10.04 s1details
#20.06 s2details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:21:5: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses]
   if(n%2!=0&&i+1!=n)
     ^

Code

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define M 1000000007

using namespace std;

int n, f;
ull ans, ff;

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> n;
	ff = n;
	for(int i=0; i<n; i++) {
		cin >> f;
		ans += (f*ff)%M;
		ans = ans%M;
		if(n%2!=0&&i+1!=n)
		if(i<n/2)
			ff++;
		else
			ff--;
	}
	cout << ans;
}

Test details

Test 1

Group: 1

Verdict:

input
100
72 66 50 11 3 15 68 45 79 11 9...

correct output
9437440

user output
541600

Test 2

Group: 2

Verdict:

input
100000
483398076 227177515 705421329 ...

correct output
179178131

user output
237534836