# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26206 | 2017-06-28T11:03:23 Z | Extazy | Boat (APIO16_boat) | C++14 | 2000 ms | 166172 KB |
#include <bits/stdc++.h> using namespace std; const int N = 517; const int TO = 1000000000; const int KEY = 314487923; const int MOD = (1e9) + 7; int n; pair < int, int > a[N]; unordered_map < int, int > it; long long ans; void update(int pos, int val) { for(;pos<=TO;pos+=pos&(pos)) it[pos]+=val,it[pos]%=MOD; } int query(int pos) { long long ans=0; for(;pos>=1;pos-=pos&(-pos)) ans+=it[pos]; return ans%MOD; } int main() { int i,j; scanf("%d", &n); for(i=1;i<=n;i++) { scanf("%d %d", &a[i].first, &a[i].second); } for(i=1;i<=n;i++) { //for(j=a[i].first;j<=a[i].second;j++) ans+=query(j-1)+1; //for(j=a[i].first;j<=a[i].second;j++) update(j,1); for(j=a[i].second;j>=a[i].first;j--) ans+=query(j-1)+1,update(j,query(j-1)+1); } ans%=MOD; printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2000 ms | 166172 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |