# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
410195 |
2021-05-22T09:00:27 Z |
amoo_safar |
Naan (JOI19_naan) |
C++17 |
|
242 ms |
49716 KB |
// vaziat meshki-ghermeze !
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'
using namespace std;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;
typedef pll frac;
bool CMP(frac A, frac B){
return A.F * B.S < A.S * B.F;
}
ll V[N];
vector<frac> cut[N];
int mk[N];
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, L;
cin >> n >> L;
for(int p = 0; p < n; p++){
ll sm = 0;
for(int i = 0; i < L; i++){
cin >> V[i];
sm += V[i];
}
int po = 0;
ll smnw = 0;
for(int it = 1; it < n; it ++){
while(n * (V[po] + smnw) <= sm * it){
smnw += V[po];
po ++;
}
frac alp = frac(it * sm - smnw * n, n * V[po]);
frac bet = frac(alp.F + po * alp.S, alp.S);
cut[p].pb(bet);
}
// cerr << p << " : ";
// for(auto [up, dw] : cut[p]) cerr << up << "/" << dw << '\n';
// cerr << '\n';
}
vector<int> P;
for(int i = 0; i < n - 1; i++){
int idx = -1;
for(int j = 0; j < n; j++){
if(mk[j])continue;
if(idx == -1) idx = j;
if(CMP(cut[j][i], cut[idx][i]))
idx = j;
}
mk[idx] = 1;
cout << cut[idx][i].F << ' ' << cut[idx][i].S << '\n';
P.pb(idx + 1);
}
for(int i = 0; i < n; i++) if(!mk[i]) P.pb(i + 1);
for(auto x : P) cout << x << ' ';
cout << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
5 ms |
5060 KB |
Output is correct |
3 |
Correct |
4 ms |
5020 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
3 ms |
4940 KB |
Output is correct |
6 |
Correct |
4 ms |
4940 KB |
Output is correct |
7 |
Correct |
4 ms |
4940 KB |
Output is correct |
8 |
Correct |
4 ms |
5036 KB |
Output is correct |
9 |
Correct |
3 ms |
5032 KB |
Output is correct |
10 |
Correct |
4 ms |
4940 KB |
Output is correct |
11 |
Correct |
5 ms |
5036 KB |
Output is correct |
12 |
Correct |
4 ms |
5068 KB |
Output is correct |
13 |
Correct |
4 ms |
5068 KB |
Output is correct |
14 |
Correct |
5 ms |
5068 KB |
Output is correct |
15 |
Correct |
5 ms |
5068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4956 KB |
Output is correct |
2 |
Correct |
4 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
5044 KB |
Output is correct |
5 |
Correct |
4 ms |
5040 KB |
Output is correct |
6 |
Correct |
4 ms |
4968 KB |
Output is correct |
7 |
Correct |
4 ms |
4952 KB |
Output is correct |
8 |
Correct |
5 ms |
5032 KB |
Output is correct |
9 |
Correct |
4 ms |
4940 KB |
Output is correct |
10 |
Correct |
4 ms |
4940 KB |
Output is correct |
11 |
Correct |
4 ms |
4940 KB |
Output is correct |
12 |
Correct |
3 ms |
4940 KB |
Output is correct |
13 |
Correct |
4 ms |
4940 KB |
Output is correct |
14 |
Correct |
4 ms |
4940 KB |
Output is correct |
15 |
Correct |
5 ms |
4940 KB |
Output is correct |
16 |
Correct |
4 ms |
5064 KB |
Output is correct |
17 |
Correct |
4 ms |
4940 KB |
Output is correct |
18 |
Correct |
5 ms |
5040 KB |
Output is correct |
19 |
Correct |
4 ms |
5068 KB |
Output is correct |
20 |
Correct |
5 ms |
4940 KB |
Output is correct |
21 |
Correct |
4 ms |
5068 KB |
Output is correct |
22 |
Correct |
4 ms |
5068 KB |
Output is correct |
23 |
Correct |
3 ms |
4940 KB |
Output is correct |
24 |
Correct |
4 ms |
4940 KB |
Output is correct |
25 |
Correct |
4 ms |
4940 KB |
Output is correct |
26 |
Correct |
4 ms |
4940 KB |
Output is correct |
27 |
Correct |
4 ms |
5068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
5 ms |
5060 KB |
Output is correct |
3 |
Correct |
4 ms |
5020 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
3 ms |
4940 KB |
Output is correct |
6 |
Correct |
4 ms |
4940 KB |
Output is correct |
7 |
Correct |
4 ms |
4940 KB |
Output is correct |
8 |
Correct |
4 ms |
5036 KB |
Output is correct |
9 |
Correct |
3 ms |
5032 KB |
Output is correct |
10 |
Correct |
4 ms |
4940 KB |
Output is correct |
11 |
Correct |
5 ms |
5036 KB |
Output is correct |
12 |
Correct |
4 ms |
5068 KB |
Output is correct |
13 |
Correct |
4 ms |
5068 KB |
Output is correct |
14 |
Correct |
5 ms |
5068 KB |
Output is correct |
15 |
Correct |
5 ms |
5068 KB |
Output is correct |
16 |
Correct |
4 ms |
4956 KB |
Output is correct |
17 |
Correct |
4 ms |
4940 KB |
Output is correct |
18 |
Correct |
4 ms |
4940 KB |
Output is correct |
19 |
Correct |
4 ms |
5044 KB |
Output is correct |
20 |
Correct |
4 ms |
5040 KB |
Output is correct |
21 |
Correct |
4 ms |
4968 KB |
Output is correct |
22 |
Correct |
4 ms |
4952 KB |
Output is correct |
23 |
Correct |
5 ms |
5032 KB |
Output is correct |
24 |
Correct |
4 ms |
4940 KB |
Output is correct |
25 |
Correct |
4 ms |
4940 KB |
Output is correct |
26 |
Correct |
4 ms |
4940 KB |
Output is correct |
27 |
Correct |
3 ms |
4940 KB |
Output is correct |
28 |
Correct |
4 ms |
4940 KB |
Output is correct |
29 |
Correct |
4 ms |
4940 KB |
Output is correct |
30 |
Correct |
5 ms |
4940 KB |
Output is correct |
31 |
Correct |
4 ms |
5064 KB |
Output is correct |
32 |
Correct |
4 ms |
4940 KB |
Output is correct |
33 |
Correct |
5 ms |
5040 KB |
Output is correct |
34 |
Correct |
4 ms |
5068 KB |
Output is correct |
35 |
Correct |
5 ms |
4940 KB |
Output is correct |
36 |
Correct |
4 ms |
5068 KB |
Output is correct |
37 |
Correct |
4 ms |
5068 KB |
Output is correct |
38 |
Correct |
3 ms |
4940 KB |
Output is correct |
39 |
Correct |
4 ms |
4940 KB |
Output is correct |
40 |
Correct |
4 ms |
4940 KB |
Output is correct |
41 |
Correct |
4 ms |
4940 KB |
Output is correct |
42 |
Correct |
4 ms |
5068 KB |
Output is correct |
43 |
Correct |
39 ms |
13652 KB |
Output is correct |
44 |
Incorrect |
242 ms |
49716 KB |
X_i is not increasing |
45 |
Halted |
0 ms |
0 KB |
- |