제출 #863131

#제출 시각아이디문제언어결과실행 시간메모리
863131AlfraganusBigger segments (IZhO19_segments)C++14
0 / 100
0 ms348 KiB
#pragma GCC optimize("unroll-loops")
#pragma gcc optimize("Ofast")
#pragma GCC optimization("Ofast")
#pragma optimize(Ofast)
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define str string
#define fastio ios::sync_with_stdio(0), cin.tie(0);
#define fs first
#define ss second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define len(x) x.size()

#define print(a)          \
    for (auto &x : a)     \
        cout << x << " "; \
    cout << endl;

#define printmp(a)    \
    for (auto &x : a) \
        cout << x.fs << " " << x.ss << endl;

const int mod = 1e9 + 7;

void solve(){
    /*
    Our small boy Askhat noticed an interesting phenomenon — trying to cover an array with “jumps” of bigger and bigger sums may not be as simple as it seems. Of course, now you need to find a way to do it.
    You are given a sequence of positive integer numbers of length N.
    Divide the given sequence into the maximal number of segments so that:
        1. Every element of the sequence belongs to exactly one segment.
        2. Sum of the numbers in every segment, except for the first one, is not less than in the previous
    */
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];    
    int ans = 0;
    for(int i = 0; i < n; i++){
        int sum = 0;
        for(int j = i; j < n; j++){
            sum += a[j];
            if(sum > a[i])
                ans++;
        }
    }
    cout << ans;
}

signed main(){
    fastio
    int t = 1;
    // cin >> t;
    while(t --){
        solve();
        cout << endl;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

segments.cpp:2: warning: ignoring '#pragma gcc optimize' [-Wunknown-pragmas]
    2 | #pragma gcc optimize("Ofast")
      | 
segments.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization("Ofast")
      | 
segments.cpp:4: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    4 | #pragma optimize(Ofast)
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...