답안 #492609

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
492609 2021-12-08T06:20:01 Z Biaz 과수원 (NOI14_orchard) C++17
0 / 25
6 ms 1100 KB
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define Nanase_Kurumi_aka_menhera_chan_is_mine ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pi pair<int, int>
#define ALL(i) i.begin(),i.end()
#define gcd(i,j) __gcd(i,j)
#define fi first
#define se second
#define eps 0.00000001
#define ist insert
#define DNE nullptr
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC optimize("O2")
int max(int x,int y){return x>=y?x:y;}
int min(int x,int y){return x>=y?y:x;}
using namespace std;
typedef int ll;
const int N=100005;
const int M=1000005;
const int MOD=1000000007;//998244353;
//const int INF=1000000000000000000;//2147483647;

int n,m,tot;
int a[N];
inline void sol(){
    cin >>n>>m;
    for (int j=1;j<=m;j++)
        cin >>a[j],a[j]+=a[j-1];
    tot=a[m];
    int ans=min(a[m],m-a[m]),mn=0;
    for (int i=1;i<=m;i++)
        a[i]=2*a[i]-i;
    for (int i=1;i<=m;i++){
        ans=max(ans,a[i]-min(a[i],mn));
        mn=min(mn,a[i]);
    }
    cout <<tot-ans<<'\n';
}
signed main(){
    Nanase_Kurumi_aka_menhera_chan_is_mine
    int _=1;
    //cin >>_;
    while (_--) sol();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1100 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1100 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -