# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
197730 | 2020-01-22T15:55:14 Z | Ruxandra985 | Strange Device (APIO19_strange_device) | C++14 | 871 ms | 68716 KB |
#include <bits/stdc++.h> #define DIMN 5000010 using namespace std; pair <long long,int> v[DIMN]; int main() { FILE *fin = stdin; FILE *fout = stdout; int n , over , elem , i , into; long long a , b, l , r , sol; fscanf (fin,"%d%lld%lld",&n,&a,&b); over = 0; if ( a > 1000000000000000000LL / b ) over = 1; elem = 0; for (i=1;i<=n;i++){ fscanf (fin,"%lld%lld",&l,&r); if (over){ /// dau resturile l si r v[++elem] = make_pair( l , 1 ); /// begin v[++elem] = make_pair( r + 1 , 0 ); /// end } else { if (r - l + 1 >= a * b){ /// sunt toate resturile v[++elem] = make_pair( 0 , 1 ); /// begin v[++elem] = make_pair( a * b , 0 ); /// end } else { l = l % (a * b); r = r % (a * b); if (l <= r){ v[++elem] = make_pair( l , 1 ); /// begin v[++elem] = make_pair( r + 1 , 0 ); /// end } else { /// se duce l .. ab - 1 0 ... r v[++elem] = make_pair( l , 1 ); /// begin v[++elem] = make_pair( a * b , 0 ); /// end v[++elem] = make_pair( 0 , 1 ); /// begin v[++elem] = make_pair( r + 1 , 0 ); /// end } } } } /// acum eu am un vector de evenimente , vr sa vad reunuiunea sol = 0; sort (v + 1 , v + elem + 1); into = 0; for ( i = 1 ; i <= elem ; i++ ){ while (i < elem && v[i].first == v[i+1].first){ if (v[i].second == 1) into++; else into--; i++; } if (i == elem) break; if (v[i].second == 1) into++; else into--; if (into > 0) sol = sol + v[i+1].first - v[i].first; } fprintf (fout,"%lld",sol); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 9 ms | 1016 KB | Output is correct |
3 | Correct | 9 ms | 1144 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 380 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 474 ms | 56952 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 675 ms | 64116 KB | Output is correct |
3 | Incorrect | 630 ms | 64112 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 675 ms | 64116 KB | Output is correct |
3 | Incorrect | 630 ms | 64112 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 675 ms | 64116 KB | Output is correct |
3 | Incorrect | 630 ms | 64112 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 73 ms | 7164 KB | Output is correct |
3 | Correct | 73 ms | 7208 KB | Output is correct |
4 | Correct | 871 ms | 68716 KB | Output is correct |
5 | Correct | 73 ms | 7288 KB | Output is correct |
6 | Correct | 72 ms | 7160 KB | Output is correct |
7 | Correct | 71 ms | 7132 KB | Output is correct |
8 | Correct | 77 ms | 7160 KB | Output is correct |
9 | Correct | 74 ms | 7288 KB | Output is correct |
10 | Correct | 77 ms | 7160 KB | Output is correct |
11 | Correct | 74 ms | 7160 KB | Output is correct |
12 | Correct | 64 ms | 7196 KB | Output is correct |
13 | Correct | 77 ms | 7160 KB | Output is correct |
14 | Correct | 766 ms | 68692 KB | Output is correct |
15 | Incorrect | 78 ms | 7124 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 9 ms | 1016 KB | Output is correct |
3 | Correct | 9 ms | 1144 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |