답안 #1007983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1007983 2024-06-26T04:43:46 Z Luvidi Feast (NOI19_feast) C++17
4 / 100
36 ms 11844 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back

void solve() {
    int n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    vector<pair<pll,pll>> v;
    ll sum=0,s=a[0]>=0,l=0,cnt=0,ans=0;
    for(int i=0;i<n;i++){
        if(s^(a[i]>=0)){
            v.pb({{abs(sum),s},{l,i-1}});
            if(s){
                cnt++;
                ans+=sum;
            }
            s=!s;
            sum=0;
            l=i;
        }
        sum+=a[i];
    }
    v.pb({{abs(sum),s},{l,n-1}});
    if(s){
        cnt++;
        ans+=sum;
    }
    bool b[n];
    for(int i=0;i<n;i++)b[i]=a[i]>=0;
    
    sort(v.begin(),v.end());
    cout<<ans;
}

int main() {   
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}

Compilation message

feast.cpp: In function 'void solve()':
feast.cpp:36:10: warning: variable 'b' set but not used [-Wunused-but-set-variable]
   36 |     bool b[n];
      |          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 2908 KB Output is correct
2 Correct 20 ms 3016 KB Output is correct
3 Correct 20 ms 3040 KB Output is correct
4 Correct 20 ms 3028 KB Output is correct
5 Correct 20 ms 2908 KB Output is correct
6 Correct 19 ms 2976 KB Output is correct
7 Correct 19 ms 2904 KB Output is correct
8 Correct 20 ms 3028 KB Output is correct
9 Correct 20 ms 2908 KB Output is correct
10 Correct 20 ms 3016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 2908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 11844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 2908 KB Output is correct
2 Correct 20 ms 3016 KB Output is correct
3 Correct 20 ms 3040 KB Output is correct
4 Correct 20 ms 3028 KB Output is correct
5 Correct 20 ms 2908 KB Output is correct
6 Correct 19 ms 2976 KB Output is correct
7 Correct 19 ms 2904 KB Output is correct
8 Correct 20 ms 3028 KB Output is correct
9 Correct 20 ms 2908 KB Output is correct
10 Correct 20 ms 3016 KB Output is correct
11 Incorrect 14 ms 2908 KB Output isn't correct
12 Halted 0 ms 0 KB -