# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
400526 |
2021-05-08T09:03:22 Z |
A_D |
Boat (APIO16_boat) |
C++14 |
|
2000 ms |
347172 KB |
#include <bits/stdc++.h>
#define int long long
#define ii pair<int,int>
#define F first
#define S second
#define du long double
using namespace std;
const int N=1e3+1;
const int M=1e6+100;
const int MOD=1e9+7;
int a[N];
int b[N];
map<int,int> mp;
set<int> st;
int seg[4*M];
void update(int p,int s,int e,int i,int v)
{
if(s==e){
seg[p]+=v;
seg[p]%=MOD;
return;
}
int mid=(s+e)/2;
if(i<=mid){
update(p*2,s,mid,i,v);
}
else{
update(p*2+1,mid+1,e,i,v);
}
seg[p]=(seg[p*2]+seg[p*2+1])%MOD;
}
int get(int p,int s,int e,int a,int b)
{
if(a<=s&&e<=b){
return seg[p];
}
if(s>b||e<a){
return 0;
}
int mid=(s+e)/2;
return (get(p*2,s,mid,a,b)+get(p*2+1,mid+1,e,a,b))%MOD;
}
void solve()
{
int n,ans=0,mn=1e9;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i]>>b[i];
for(int j=a[i];j<=b[i];j++){
st.insert(j);
}
}
int cnt=2;
for(auto x:st)mp[x]=cnt++;
for(int i=1;i<=n;i++){
a[i]=mp[a[i]];
b[i]=mp[b[i]];
for(int j=b[i];j>=a[i];j--){
int v=get(1,1,M,1,j-1)+1;
ans+=v;
ans%=MOD;
update(1,1,M,j,v);
}
}
cout<<ans<<endl;
}
main()
{
int t=1;
// cin>>t;
while(t--)solve();
}
Compilation message
boat.cpp: In function 'void solve()':
boat.cpp:45:17: warning: unused variable 'mn' [-Wunused-variable]
45 | int n,ans=0,mn=1e9;
| ^~
boat.cpp: At global scope:
boat.cpp:67:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
67 | main()
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
440 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
2 ms |
312 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
440 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
2 ms |
312 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
461 ms |
1016 KB |
Output is correct |
22 |
Correct |
457 ms |
1016 KB |
Output is correct |
23 |
Correct |
427 ms |
1020 KB |
Output is correct |
24 |
Correct |
471 ms |
1056 KB |
Output is correct |
25 |
Correct |
478 ms |
1068 KB |
Output is correct |
26 |
Correct |
499 ms |
844 KB |
Output is correct |
27 |
Correct |
499 ms |
964 KB |
Output is correct |
28 |
Correct |
508 ms |
852 KB |
Output is correct |
29 |
Correct |
501 ms |
836 KB |
Output is correct |
30 |
Correct |
1100 ms |
124800 KB |
Output is correct |
31 |
Correct |
1063 ms |
122716 KB |
Output is correct |
32 |
Correct |
1085 ms |
124924 KB |
Output is correct |
33 |
Correct |
1039 ms |
121724 KB |
Output is correct |
34 |
Correct |
1119 ms |
122796 KB |
Output is correct |
35 |
Correct |
972 ms |
117224 KB |
Output is correct |
36 |
Correct |
1000 ms |
121300 KB |
Output is correct |
37 |
Correct |
1027 ms |
122692 KB |
Output is correct |
38 |
Correct |
993 ms |
118724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2099 ms |
347172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
440 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
2 ms |
312 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
461 ms |
1016 KB |
Output is correct |
22 |
Correct |
457 ms |
1016 KB |
Output is correct |
23 |
Correct |
427 ms |
1020 KB |
Output is correct |
24 |
Correct |
471 ms |
1056 KB |
Output is correct |
25 |
Correct |
478 ms |
1068 KB |
Output is correct |
26 |
Correct |
499 ms |
844 KB |
Output is correct |
27 |
Correct |
499 ms |
964 KB |
Output is correct |
28 |
Correct |
508 ms |
852 KB |
Output is correct |
29 |
Correct |
501 ms |
836 KB |
Output is correct |
30 |
Correct |
1100 ms |
124800 KB |
Output is correct |
31 |
Correct |
1063 ms |
122716 KB |
Output is correct |
32 |
Correct |
1085 ms |
124924 KB |
Output is correct |
33 |
Correct |
1039 ms |
121724 KB |
Output is correct |
34 |
Correct |
1119 ms |
122796 KB |
Output is correct |
35 |
Correct |
972 ms |
117224 KB |
Output is correct |
36 |
Correct |
1000 ms |
121300 KB |
Output is correct |
37 |
Correct |
1027 ms |
122692 KB |
Output is correct |
38 |
Correct |
993 ms |
118724 KB |
Output is correct |
39 |
Execution timed out |
2099 ms |
347172 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |