Submission #708107

# Submission time Handle Problem Language Result Execution time Memory
708107 2023-03-11T05:25:29 Z veehj Strange Device (APIO19_strange_device) C++17
5 / 100
1690 ms 63240 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()
 
int main() {
  ll n, a, b; cin >> n >> a >> b;
  map<ll, ll> mp;
  while(n--){
    ll l, r; cin >> l >> r;
    l%=a*b;
    r%=a*b; 
    if(l>r){
      mp[l]++;
      mp[a*b]--;
      mp[0]++;
      mp[r+1]--;
    }
    else{
      mp[l]++;
      mp[r+1]--;
    }
  }
  // 1 0 1 -1 -1 0 1 0 -1
  // 1 1 2  1  0 0 1 1  0
  ll cnt=0, nw=0, ans=0, bul=0;
  for(auto& u : mp){
    cnt+=u.S;
    // cout << "[" << u.first << ',' << u.second << ']' << cnt << endl;
    if(!bul){
      nw=u.F;
    }
    if(cnt) bul=1;
    else{
      ans+=u.F-nw;
      // cout << ans << endl;
      bul=0;
    }
  }
  cout << ans;
} 
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 17 ms 1004 KB Output is correct
3 Correct 17 ms 980 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 862 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1539 ms 63132 KB Output is correct
3 Incorrect 1603 ms 63240 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1539 ms 63132 KB Output is correct
3 Incorrect 1603 ms 63240 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1539 ms 63132 KB Output is correct
3 Incorrect 1603 ms 63240 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 163 ms 6668 KB Output is correct
3 Correct 252 ms 6676 KB Output is correct
4 Correct 1638 ms 63056 KB Output is correct
5 Correct 154 ms 6620 KB Output is correct
6 Correct 159 ms 6560 KB Output is correct
7 Correct 168 ms 6636 KB Output is correct
8 Correct 162 ms 6580 KB Output is correct
9 Correct 150 ms 6608 KB Output is correct
10 Correct 147 ms 6656 KB Output is correct
11 Correct 169 ms 6684 KB Output is correct
12 Correct 153 ms 6620 KB Output is correct
13 Correct 155 ms 6668 KB Output is correct
14 Correct 1690 ms 63128 KB Output is correct
15 Incorrect 168 ms 6708 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 17 ms 1004 KB Output is correct
3 Correct 17 ms 980 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -