답안 #291637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
291637 2020-09-05T14:57:45 Z crossing0ver Discharging (NOI20_discharging) C++17
컴파일 오류
0 ms 0 KB
#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

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() {
      |        ^