Contest Duration: ~ (local time) (90 minutes) Back to Home

Submission #470897

Source Code Expand

Copy
```#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const ll M = 1000000007;

int main(){
static int n;
static int d[100010];
scanf("%d",&n);
rep(i,n){
scanf("%d",&d[i]);
}

vector<int> vec;
rep(i,n)vec.pb(d[i]);
sor(vec);

static ll dp[100010][4] = {};
rep(i,n){
dp[i][0] = 1;
if(i > 0)dp[i][0] += dp[i-1][0];
int l = ub(vec,vec[i]/2) - vec.begin();
l --;
if(l >= 0){
rep1(j,3){
dp[i][j] = dp[l][j-1];
if(i > 0)dp[i][j] += dp[i-1][j];
dp[i][j] %= M;
}
}
/*rep(j,4){
printf("%lld ",dp[i][j]);
}
puts("");*/
}

cout << dp[n-1][3] << endl;
}

```

Submission Info

Submission Time 2015-08-15 22:22:49+0900 B - 難易度 yokozuna57 C++11 (GCC 4.9.2) 100 1590 Byte AC 77 ms 4768 KB

Compile Error

```./Main.cpp: In function ‘int main()’:
./Main.cpp:42:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:44:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&d[i]);
^
```

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt 25 ms 804 KB
sample_02.txt 26 ms 924 KB
sample_03.txt 26 ms 800 KB