Submission #61187

#TimeUsernameProblemLanguageResultExecution timeMemory
61187dukati8Boat (APIO16_boat)C++14
9 / 100
2084 ms525312 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...