답안 #291485

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
291485 2020-09-05T11:36:50 Z crossing0ver Discharging (NOI20_discharging) C++17
11 / 100
847 ms 18040 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() {
    cin >> n;
    int tot = n;
    for (int i = 1; i <= n; i++)
            cin >> arr[i];
    int mx = 0,k = 0,block = 0;
    for (int i = 1; i <= n; i++) {
          //  block++;
        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+1);
                    ans += mx;
                    k += arr[i] - mx;
                    mx = arr[i];
                    }
            else ans += k;

       // if (mx < arr[i]) mx = arr[i], k += arr[i] - mx;
        }
        mx = max(mx,arr[i]);
     //  ans += k;
        block++;
    }
    cout << ans;

}

Compilation message

Discharging.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main() {
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 841 ms 17772 KB Output is correct
2 Correct 847 ms 17784 KB Output is correct
3 Correct 836 ms 17844 KB Output is correct
4 Correct 845 ms 17692 KB Output is correct
5 Correct 845 ms 17740 KB Output is correct
6 Correct 843 ms 17856 KB Output is correct
7 Correct 828 ms 17804 KB Output is correct
8 Correct 836 ms 17984 KB Output is correct
9 Correct 836 ms 18040 KB Output is correct
10 Correct 838 ms 17912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -