Task: | Keskiarvot |
Sender: | tuomask |
Submission time: | 2018-01-07 21:03:59 +0200 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:5:10: error: 'n' was not declared in this scope cin >> n; ^ input/code.cpp:7:34: error: 't' was not declared in this scope for (int i=0; i<n; i++) cin >> t[i]; ^ input/code.cpp:13:14: error: 't' was not declared in this scope sum += t[a]; ^
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { cin >> n; int t[n]; for (int i=0; i<n; i++) cin >> t[i]; for (int i=0; i<n; i++) { int suur = 0; int pit; ll sum = 0; for (int a=i; a>=0; a--) { sum += t[a]; int ka = sum / (i-a+1); if (ka >= suur) { suur = ka; pit = (i-a+1); } } cout << pit << " "; } cout << "\n"; }