Submission #472922

#TimeUsernameProblemLanguageResultExecution timeMemory
472922fuad27Addk (eJOI21_addk)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define int long long using namespace std; int32_t main () { int n, k; cin >> n >> k; int arr[n]; for(int i = 0;i<n;i++) { cin >> arr[i]; } int q; cin >> q; while(q--) { int k; cin >> k; if(k == 1) { int d; cin >> d; } else { int ans = 0; int l, r, m; cin >> l >> r >> m; l--; m = min(m, r-l-m + 2) for(int i = l;i<r;i++) { ans += min(m, min(i-l+1, r-i))*arr[i]; } cout<<ans<<endl; } } }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:26:33: error: expected ';' before 'for'
   26 |            m = min(m, r-l-m + 2)
      |                                 ^
      |                                 ;
   27 |    for(int i = l;i<r;i++) {
      |    ~~~                           
Main.cpp:27:18: error: 'i' was not declared in this scope
   27 |    for(int i = l;i<r;i++) {
      |                  ^