# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
22076 | 2017-04-29T07:14:50 Z | 아재 goto 써요?(#1011, baactree) | 구간들 (KRIII5P_3) | C++14 | 113 ms | 5180 KB |
// ===================================================================================== // // Filename: i.cpp // Created: 2017년 04월 29일 15시 53분 37초 // Compiler: g++ -O2 -std=c++14 // Author: baactree , [email protected] // Company: Chonnam National University // // ===================================================================================== #include <bits/stdc++.h> using namespace std; int n; vector<pair<int, int> > event; const int mod=1000000007; typedef long long ll; ll _pow(ll a, ll b){ if(b==0) return 1; ll temp=_pow(a, b/2); temp=(temp*temp)%mod; if(b&1) return (temp*a)%mod; return temp; } int main(){ scanf("%d", &n); for(int i=0;i<n;i++){ int a, b; scanf("%d%d", &a, &b); if(a>=b) continue; event.push_back({a, 1}); event.push_back({b, 0}); } sort(event.begin(), event.end()); int cnt=0; ll len=0; ll ans=0; int pre=0; for(int i=0;i<event.size();i++){ int x=event[i].first; int m=event[i].second; len+=(long long)(x-pre)*(_pow(2, cnt)-1+mod); len%=mod; if(m){ ans+=_pow(2, cnt); ans%=mod; cnt++; } else{ cnt--; } pre=x; } printf("%lld %lld\n", len, ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2024 KB | Output is correct |
2 | Correct | 0 ms | 2024 KB | Output is correct |
3 | Correct | 0 ms | 2024 KB | Output is correct |
4 | Correct | 0 ms | 2024 KB | Output is correct |
5 | Correct | 0 ms | 2024 KB | Output is correct |
6 | Correct | 9 ms | 2492 KB | Output is correct |
7 | Correct | 6 ms | 2492 KB | Output is correct |
8 | Correct | 6 ms | 2492 KB | Output is correct |
9 | Correct | 6 ms | 2492 KB | Output is correct |
10 | Correct | 6 ms | 2492 KB | Output is correct |
11 | Correct | 83 ms | 5180 KB | Output is correct |
12 | Correct | 89 ms | 5180 KB | Output is correct |
13 | Correct | 83 ms | 5180 KB | Output is correct |
14 | Correct | 83 ms | 5180 KB | Output is correct |
15 | Correct | 89 ms | 5180 KB | Output is correct |
16 | Correct | 63 ms | 3644 KB | Output is correct |
17 | Correct | 63 ms | 3644 KB | Output is correct |
18 | Correct | 63 ms | 3644 KB | Output is correct |
19 | Correct | 66 ms | 3644 KB | Output is correct |
20 | Correct | 56 ms | 3644 KB | Output is correct |
21 | Correct | 89 ms | 5180 KB | Output is correct |
22 | Correct | 93 ms | 5180 KB | Output is correct |
23 | Correct | 93 ms | 5180 KB | Output is correct |
24 | Correct | 93 ms | 5180 KB | Output is correct |
25 | Correct | 66 ms | 5180 KB | Output is correct |
26 | Correct | 96 ms | 5180 KB | Output is correct |
27 | Correct | 89 ms | 5180 KB | Output is correct |
28 | Correct | 89 ms | 5180 KB | Output is correct |
29 | Correct | 113 ms | 5180 KB | Output is correct |
30 | Correct | 96 ms | 5180 KB | Output is correct |
31 | Correct | 86 ms | 5180 KB | Output is correct |
32 | Correct | 89 ms | 5180 KB | Output is correct |
33 | Correct | 96 ms | 5180 KB | Output is correct |
34 | Correct | 99 ms | 5180 KB | Output is correct |
35 | Correct | 76 ms | 5180 KB | Output is correct |
36 | Correct | 86 ms | 5180 KB | Output is correct |
37 | Correct | 109 ms | 5180 KB | Output is correct |
38 | Correct | 86 ms | 5180 KB | Output is correct |
39 | Correct | 93 ms | 5180 KB | Output is correct |
40 | Correct | 89 ms | 5180 KB | Output is correct |
41 | Correct | 0 ms | 2024 KB | Output is correct |
42 | Correct | 0 ms | 2024 KB | Output is correct |
43 | Correct | 3 ms | 2164 KB | Output is correct |
44 | Correct | 3 ms | 2164 KB | Output is correct |
45 | Correct | 36 ms | 3644 KB | Output is correct |
46 | Correct | 39 ms | 3644 KB | Output is correct |
47 | Correct | 46 ms | 3644 KB | Output is correct |
48 | Correct | 83 ms | 5180 KB | Output is correct |
49 | Correct | 76 ms | 5180 KB | Output is correct |
50 | Correct | 79 ms | 5180 KB | Output is correct |