# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
22209 |
2017-04-29T23:58:38 Z |
sgc109(#1015, sgc109) |
None (KRIII5P_3) |
C++11 |
|
79 ms |
15284 KB |
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define FOR(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define inp1(a) scanf("%d",&a)
#define inp2(a,b) scanf("%d%d",&a,&b)
#define inp3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define inp4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define inp5(a,b,c,d,e) scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define fastio() ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vector<int> > vvi;
typedef pair<int,pair<int,int> > piii;
typedef vector<piii> viii;
const double EPSILON = 1e-9;
const double PI = acos(-1);
const int MOD = 1e9+7;
const int INF = 0x3c3c3c3c;
const long long INFL = 0x3c3c3c3c3c3c3c3c;
const int MAX_N = 102;
int N;
set<ll> st;
vll range;
vl comp;
ll t[800003];
ll pow2[100003];
int size;
vll v;
void update(int pos, int v){
while(pos <= size){
t[pos] += v;
pos += pos&-pos;
}
}
ll query(int pos){
ll ret = 0;
while(pos > 0){
ret += t[pos];
pos -= pos&-pos;
}
return ret;
}
bool cmp(pll& A, pll& B){
if(A.second != B.second) return A.second < B.second;
return A.first < B.first;
}
int main() {
inp1(N);
int cnt = 0;
FOR(i,N){
ll a,b;
scanf("%lld%lld",&a,&b);
if(a>=b) {
cnt++;
continue;
}
v.pb({a,1});
v.pb({b,-1});
}
N-=cnt;
sort(all(v));
pow2[0] = 1;
FOR(i,100001) pow2[i+1] = (pow2[i] * 2) % MOD;
ll sum = 0;
int on = 0;
FOR(i,sz(v)){
on += v[i].second;
if(!on) continue;
if(i!=sz(v)-1) sum = (sum + (v[i+1].first-v[i].first)*(pow2[on]-1)) % MOD;;
}
int prev = 0;
int cur = 0;
ll ans = 0;
on = 0;
FOR(i,sz(v)){
on += v[i].second;
if(v[i].second == 1 && (i == sz(v)-1 || v[i+1].second == -1)){
cur++;
ans = (ans + pow2[prev]*(pow2[cur]-1)) % MOD;
prev += cur;
cur = 0;
}
if(v[i].second == 1 && (i < sz(v)-1 && v[i+1].second == 1)) cur++;
if(v[i].second == -1) prev--;
}
printf("%lld %lld",sum, ans);
return 0;
}
Compilation message
i.cpp: In function 'int main()':
i.cpp:61:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
inp1(N);
^
i.cpp:65:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&a,&b);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9196 KB |
Output is correct |
2 |
Correct |
0 ms |
9196 KB |
Output is correct |
3 |
Correct |
0 ms |
9196 KB |
Output is correct |
4 |
Correct |
0 ms |
9196 KB |
Output is correct |
5 |
Correct |
0 ms |
9196 KB |
Output is correct |
6 |
Correct |
6 ms |
9908 KB |
Output is correct |
7 |
Correct |
6 ms |
9908 KB |
Output is correct |
8 |
Correct |
3 ms |
9908 KB |
Output is correct |
9 |
Correct |
6 ms |
9908 KB |
Output is correct |
10 |
Correct |
6 ms |
9908 KB |
Output is correct |
11 |
Correct |
53 ms |
15284 KB |
Output is correct |
12 |
Correct |
46 ms |
15284 KB |
Output is correct |
13 |
Correct |
49 ms |
15284 KB |
Output is correct |
14 |
Correct |
56 ms |
15284 KB |
Output is correct |
15 |
Correct |
43 ms |
15284 KB |
Output is correct |
16 |
Correct |
36 ms |
12212 KB |
Output is correct |
17 |
Correct |
39 ms |
12212 KB |
Output is correct |
18 |
Correct |
43 ms |
12212 KB |
Output is correct |
19 |
Correct |
63 ms |
12212 KB |
Output is correct |
20 |
Correct |
36 ms |
12212 KB |
Output is correct |
21 |
Correct |
53 ms |
15284 KB |
Output is correct |
22 |
Correct |
56 ms |
15284 KB |
Output is correct |
23 |
Correct |
59 ms |
15284 KB |
Output is correct |
24 |
Correct |
53 ms |
15284 KB |
Output is correct |
25 |
Correct |
46 ms |
15284 KB |
Output is correct |
26 |
Correct |
53 ms |
15284 KB |
Output is correct |
27 |
Correct |
79 ms |
15284 KB |
Output is correct |
28 |
Correct |
59 ms |
15284 KB |
Output is correct |
29 |
Correct |
49 ms |
15284 KB |
Output is correct |
30 |
Correct |
56 ms |
15284 KB |
Output is correct |
31 |
Correct |
63 ms |
15284 KB |
Output is correct |
32 |
Correct |
53 ms |
15284 KB |
Output is correct |
33 |
Correct |
63 ms |
15284 KB |
Output is correct |
34 |
Correct |
56 ms |
15284 KB |
Output is correct |
35 |
Correct |
66 ms |
15284 KB |
Output is correct |
36 |
Correct |
69 ms |
15284 KB |
Output is correct |
37 |
Correct |
53 ms |
15284 KB |
Output is correct |
38 |
Correct |
69 ms |
15284 KB |
Output is correct |
39 |
Correct |
53 ms |
15284 KB |
Output is correct |
40 |
Correct |
59 ms |
15284 KB |
Output is correct |
41 |
Correct |
0 ms |
9196 KB |
Output is correct |
42 |
Correct |
0 ms |
9196 KB |
Output is correct |
43 |
Correct |
3 ms |
9328 KB |
Output is correct |
44 |
Correct |
3 ms |
9328 KB |
Output is correct |
45 |
Correct |
19 ms |
12212 KB |
Output is correct |
46 |
Correct |
26 ms |
12212 KB |
Output is correct |
47 |
Correct |
13 ms |
12212 KB |
Output is correct |
48 |
Correct |
49 ms |
15284 KB |
Output is correct |
49 |
Correct |
46 ms |
15284 KB |
Output is correct |
50 |
Correct |
36 ms |
15284 KB |
Output is correct |