CODE THANKS FESTIVAL 2018(Parallel)

Submission #11204482

Source codeソースコード

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
ll a[1010],S[1010];
int dp[2][1010];

void solve(){
    cin >> n;
    ll l=-INF,r=INF;
    rep(i,n){
        cin >> a[i];
        S[i+1]=S[i]+a[i];
    }
    while(r-l>1){
        ll mid=(r+l)/2;
        //cout << mid << endl;
        rep(i,n){
            dp[0][i]=mod;
            dp[1][i]=-mod;
        }
        dp[0][n]=0;
        dp[1][n]=0;
        per(i,n){
            Rep(j,i+1,n+1){
                dp[0][i]=min(dp[0][i],dp[1][j]-(S[j]-S[i]>=mid));
                dp[1][i]=max(dp[1][i],dp[0][j]-(S[j]-S[i]>=mid));
            }
        }

        // rep(k,2){
        //     rep(i,n+1){
        //         cout << k << " " << i << " " << dp[k][i] << endl;
        //     }
        // }
        if(dp[0][0]>=0) r=mid;
        else l=mid;
    }
    cout << l << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Submission

Task問題 H - Median Game
User nameユーザ名 Chanyuh
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1908 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - s1.txt,s2.txt
All 0 / 500 01.txt,02.txt,03.txt,04.txt,05.txt,06.txt,07.txt,08.txt,09.txt,10.txt,11.txt,12.txt,13.txt,14.txt,15.txt,16.txt,17.txt,18.txt,19.txt,20.txt,21.txt,22.txt,23.txt,24.txt,25.txt,26.txt,27.txt,28.txt,29.txt,30.txt,s1.txt,s2.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01.txt AC 1 ms 256 KB
02.txt WA
03.txt WA
04.txt AC 1 ms 256 KB
05.txt WA
06.txt AC 1 ms 256 KB
07.txt WA
08.txt WA
09.txt WA
10.txt AC 1 ms 256 KB
11.txt WA
12.txt WA
13.txt WA
14.txt WA
15.txt WA
16.txt WA
17.txt WA
18.txt WA
19.txt WA
20.txt WA
21.txt WA
22.txt WA
23.txt WA
24.txt WA
25.txt WA
26.txt WA
27.txt WA
28.txt WA
29.txt WA
30.txt WA
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB