Submission #972889

#TimeUsernameProblemLanguageResultExecution timeMemory
972889UnforgettableplStrange Device (APIO19_strange_device)C++17
0 / 100
5012 ms524288 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,A,B; cin >> n >> A >> B; int modulus; bool edgecase = false; if((B+1)%A==0){ modulus = B; } else { modulus = A*B; if(INT64_MAX/A<B or INT64_MAX/B<A)edgecase=true; } int totalsum = 0; set<int> answers; for(int i=1;i<=n;i++){ int l,r;cin>>l>>r; for(int x=l;x<=r;x++){ totalsum++; answers.insert(x%modulus); } } if(edgecase)cout << totalsum << '\n'; else cout << answers.size() << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...