# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
248352 |
2020-07-12T09:32:14 Z |
VEGAnn |
Sirni (COCI17_sirni) |
C++14 |
|
102 ms |
49784 KB |
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define PB push_back
#define i2 array<int,2>
using namespace std;
typedef long long ll;
const int N = 100100;
const int BIG = int(1e7) + 10;
const int cn = int(1e4);
const int oo = 2e9;
bool mrk[BIG];
vector<i2> edg;
vector<int> vc;
int n, nt[BIG];
ll ans = 0;
int get(int x) { return (x == nt[x] ? x : nt[x] = get(nt[x])); }
void calc(){
for (int i = BIG - 2; i > 0; i--)
if (mrk[i])
nt[i] = i;
else nt[i] = nt[i + 1];
for (int cr : vc){
int cm = mrk[cr];
int x = cr;
nt[get(x)] = get(x + 1);
for (int i = get(x); i < BIG - 1; ){
int nw = i % x;
edg.PB({i, x});
if (nw == 0)
i += x;
else i += x - nw;
i = get(i);
}
}
}
bool cmp(i2 _x, i2 _y){
return (_x[0] % _x[1]) < (_y[0] % _y[1]);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n;
for (int i = 1; i <= n; i++){
int x; cin >> x;
mrk[x] = 1;
}
int siz = 0;
for (int i = 1; i < BIG; i++)
if (mrk[i]) {
siz++;
vc.PB(i);
}
nt[BIG - 1] = BIG - 1;
reverse(all(vc));
calc();
sort(all(edg), cmp);
for (int cr : vc)
nt[cr] = cr;
for (i2 nw : edg){
int x = get(nw[0]), y = get(nw[1]);
if (x == y) continue;
ans += nw[0] % nw[1];
nt[x] = y;
}
cout << ans << '\n';
return 0;
}
Compilation message
sirni.cpp: In function 'void calc()':
sirni.cpp:27:13: warning: unused variable 'cm' [-Wunused-variable]
int cm = mrk[cr];
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
76 ms |
42620 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
75 ms |
39544 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
77 ms |
42796 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
90 ms |
40948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
79 ms |
40540 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
90 ms |
40960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
81 ms |
40056 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
102 ms |
49776 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
101 ms |
49784 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
85 ms |
49528 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |