답안 #83540

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83540 2018-11-08T20:58:48 Z nikolapesic2802 Calvinball championship (CEOI15_teams) C++14
70 / 100
17 ms 8820 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; ///find_by_order(),order_of_key()

const int N=1e3+5;
const int mod=1e6+7;
int dp[N][N]; /// dp[x][y] Number of ways to choose x numbers if the max so far is y
int pref[N];
int add(int a,int b){
    a+=b;
    if(a>mod)
        a-=mod;
    return a;
}
int sub(int a,int b)
{
    a-=b;
    if(a<0)
        a+=mod;
    return a;
}
int get(int l,int r)
{
    if(l==0)
        return pref[r];
    return sub(pref[r],pref[l-1]);
}
int main()
{
    for(int i=0;i<N;i++)
        dp[0][i]=1;
    for(int n=1;n<N;n++)
    {
        pref[0]=dp[n-1][0];
        for(int i=1;i<N;i++)
        {
            pref[i]=add(pref[i-1],dp[n-1][i]);
        }
        for(int i=0;i<N-1;i++)
        {
            dp[n][i]=add(((ll)dp[n-1][i]*(i+1))%mod,dp[n-1][i+1]);
        }
    }
    int n;
    scanf("%i",&n);
    /*vector<int> a(n);
    for(int i=0;i<n;i++)
        scanf("%i",&a[i]);*/
    int res=0;
    int tr=0;
    for(int i=0;i<n;i++){
        int a;
        scanf("%i",&a);
        //printf("%i %i\n",n-i-1,tr);
        res=add(res,((ll)(a-1)*dp[n-i-1][tr-2])%mod);
        //printf("%i\n",res);
        tr=max(tr,a+1);
    }
    res++;
    printf("%i\n",res);
    return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:53:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&n);
     ~~~~~^~~~~~~~~
teams.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i",&a);
         ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 4348 KB Output is correct
2 Correct 12 ms 4468 KB Output is correct
3 Correct 12 ms 4512 KB Output is correct
4 Correct 11 ms 4512 KB Output is correct
5 Correct 11 ms 4512 KB Output is correct
6 Correct 11 ms 4512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 4512 KB Output is correct
2 Correct 11 ms 4512 KB Output is correct
3 Correct 11 ms 4592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 4592 KB Output is correct
2 Correct 11 ms 4592 KB Output is correct
3 Correct 11 ms 4592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 4592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 4592 KB Output is correct
2 Correct 11 ms 4592 KB Output is correct
3 Correct 11 ms 4636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 4636 KB Output is correct
2 Correct 11 ms 4636 KB Output is correct
3 Correct 11 ms 4636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4636 KB Output is correct
2 Correct 11 ms 4668 KB Output is correct
3 Correct 12 ms 4668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 8660 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 17 ms 8820 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 17 ms 8820 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -