Submission #291637

#TimeUsernameProblemLanguageResultExecution timeMemory
291637crossing0verDischarging (NOI20_discharging)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define int long long #define ll long long #define fi first #define se second #define pii pair<int,int> #define vi vector<int> using namespace std; const int N = 1e6+6; //ll ans; int n,arr[N]; main() { int t = 10; cin >> n; int tot = n; for (int i = 1; i <= n; i++) { cin >> arr[i]; ll ans = 0; int mx = 0,k = 0,block = 0; for (int i = 1; i <= n; i++) { if (tot*mx <= block*arr[i]) { block = 0; k += arr[i]; tot = n - i+1; ans += k; } else { if (mx < arr[i]) { ans += (arr[i] - mx)*(block); k += arr[i] - mx; ans+=k; mx = arr[i]; } else ans += k; } mx = max(mx,arr[i]); block++; } cout << ans <<'\n'; }

Compilation message (stderr)

Discharging.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main() {
      |      ^
Discharging.cpp: In function 'int main()':
Discharging.cpp:13:9: warning: unused variable 't' [-Wunused-variable]
   13 |     int t = 10;
      |         ^
Discharging.cpp:43:1: error: expected '}' at end of input
   43 | }
      | ^
Discharging.cpp:12:8: note: to match this '{'
   12 | main() {
      |        ^