Submission #291639

# Submission time Handle Problem Language Result Execution time Memory
291639 2020-09-05T14:58:21 Z crossing0ver Discharging (NOI20_discharging) C++17
11 / 100
838 ms 9976 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;
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 832 ms 9848 KB Output is correct
2 Correct 820 ms 9812 KB Output is correct
3 Correct 838 ms 9732 KB Output is correct
4 Correct 838 ms 9848 KB Output is correct
5 Correct 826 ms 9752 KB Output is correct
6 Correct 836 ms 9860 KB Output is correct
7 Correct 832 ms 9808 KB Output is correct
8 Correct 829 ms 9848 KB Output is correct
9 Correct 836 ms 9876 KB Output is correct
10 Correct 829 ms 9976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -