# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
61187 |
2018-07-25T10:25:26 Z |
dukati8 |
Boat (APIO16_boat) |
C++14 |
|
2000 ms |
525312 KB |
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=a; i<int(b); i++)
long long m=1e9+7;
int main() {
int n;
cin >> n;
vector<long long> a(n);
vector<long long> b(n);
rep(i,0,n) {
cin >> a[i] >> b[i];
}
unordered_map<long long, long long> x;
x[0]=1;
rep (i,0,n) {
long long lo,hi;
lo=a[i];
hi=b[i];
long long sum=0;
vector<pair<long long, long long>> save;
for (auto c:x) {
long long size=c.first;
long long num=c.second;
//cout << size << " " << num << endl;
if (size<lo) {sum+=num; sum%=m;}
else if (size<hi) save.push_back(c);
}
//cout << endl;
sort(save.begin(),save.end());
long long j=0;
rep (i,lo,hi+1) {
while(j<save.size() &&save[j].first<i) {
sum+=save[j].second;
sum&=m;
j++;
}
if (x.find(i)==x.end()) {
x[i]=sum;
}
else {
x[i]+=sum;
x[i]%=m;
}
}
}
long long sum=0;
for (auto c:x){
sum+=c.second;
sum%=m;
//cout << c.first << " " << c.second << endl;
}
sum+=m;
sum-=1;
sum%=m;
cout << sum << endl;
}
Compilation message
boat.cpp: In function 'int main()':
boat.cpp:34:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(j<save.size() &&save[j].first<i) {
~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
248 KB |
Output is correct |
2 |
Correct |
4 ms |
356 KB |
Output is correct |
3 |
Correct |
5 ms |
564 KB |
Output is correct |
4 |
Correct |
5 ms |
564 KB |
Output is correct |
5 |
Correct |
4 ms |
564 KB |
Output is correct |
6 |
Correct |
6 ms |
564 KB |
Output is correct |
7 |
Correct |
6 ms |
564 KB |
Output is correct |
8 |
Correct |
6 ms |
636 KB |
Output is correct |
9 |
Correct |
7 ms |
636 KB |
Output is correct |
10 |
Correct |
6 ms |
636 KB |
Output is correct |
11 |
Correct |
6 ms |
684 KB |
Output is correct |
12 |
Correct |
5 ms |
688 KB |
Output is correct |
13 |
Correct |
6 ms |
688 KB |
Output is correct |
14 |
Correct |
5 ms |
688 KB |
Output is correct |
15 |
Correct |
7 ms |
688 KB |
Output is correct |
16 |
Correct |
4 ms |
688 KB |
Output is correct |
17 |
Correct |
4 ms |
688 KB |
Output is correct |
18 |
Correct |
3 ms |
688 KB |
Output is correct |
19 |
Correct |
3 ms |
688 KB |
Output is correct |
20 |
Correct |
4 ms |
688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
248 KB |
Output is correct |
2 |
Correct |
4 ms |
356 KB |
Output is correct |
3 |
Correct |
5 ms |
564 KB |
Output is correct |
4 |
Correct |
5 ms |
564 KB |
Output is correct |
5 |
Correct |
4 ms |
564 KB |
Output is correct |
6 |
Correct |
6 ms |
564 KB |
Output is correct |
7 |
Correct |
6 ms |
564 KB |
Output is correct |
8 |
Correct |
6 ms |
636 KB |
Output is correct |
9 |
Correct |
7 ms |
636 KB |
Output is correct |
10 |
Correct |
6 ms |
636 KB |
Output is correct |
11 |
Correct |
6 ms |
684 KB |
Output is correct |
12 |
Correct |
5 ms |
688 KB |
Output is correct |
13 |
Correct |
6 ms |
688 KB |
Output is correct |
14 |
Correct |
5 ms |
688 KB |
Output is correct |
15 |
Correct |
7 ms |
688 KB |
Output is correct |
16 |
Correct |
4 ms |
688 KB |
Output is correct |
17 |
Correct |
4 ms |
688 KB |
Output is correct |
18 |
Correct |
3 ms |
688 KB |
Output is correct |
19 |
Correct |
3 ms |
688 KB |
Output is correct |
20 |
Correct |
4 ms |
688 KB |
Output is correct |
21 |
Incorrect |
117 ms |
1040 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2084 ms |
525312 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
248 KB |
Output is correct |
2 |
Correct |
4 ms |
356 KB |
Output is correct |
3 |
Correct |
5 ms |
564 KB |
Output is correct |
4 |
Correct |
5 ms |
564 KB |
Output is correct |
5 |
Correct |
4 ms |
564 KB |
Output is correct |
6 |
Correct |
6 ms |
564 KB |
Output is correct |
7 |
Correct |
6 ms |
564 KB |
Output is correct |
8 |
Correct |
6 ms |
636 KB |
Output is correct |
9 |
Correct |
7 ms |
636 KB |
Output is correct |
10 |
Correct |
6 ms |
636 KB |
Output is correct |
11 |
Correct |
6 ms |
684 KB |
Output is correct |
12 |
Correct |
5 ms |
688 KB |
Output is correct |
13 |
Correct |
6 ms |
688 KB |
Output is correct |
14 |
Correct |
5 ms |
688 KB |
Output is correct |
15 |
Correct |
7 ms |
688 KB |
Output is correct |
16 |
Correct |
4 ms |
688 KB |
Output is correct |
17 |
Correct |
4 ms |
688 KB |
Output is correct |
18 |
Correct |
3 ms |
688 KB |
Output is correct |
19 |
Correct |
3 ms |
688 KB |
Output is correct |
20 |
Correct |
4 ms |
688 KB |
Output is correct |
21 |
Incorrect |
117 ms |
1040 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |