제출 #604172

#제출 시각아이디문제언어결과실행 시간메모리
604172HamletPetrosyan식물 비교 (IOI20_plants)C++17
0 / 100
4074 ms4344 KiB
#include "plants.h" #include <iostream> #include <algorithm> using namespace std; #define len(a) ((int)(a).size()) vector<int> v, m, c; int compare_plants(int x, int y) { if(v[x] > v[y]) return 1; return -1; } void init(int k, vector<int> r) { v.resize(len(r)); m.resize(len(r)); c.resize(len(r)); int x = len(r); while(x--){ // cout << x << " "; for(int i = 0; i < len(r); i++){ m[i] = 1000000009; c[i] = 0; for(int j = i + 1; j < i + k; j++){ if(r[j % len(r)] == -1) c[i]++; } for(int j = i + len(r) - 1; j > i + len(r) - k; j--){ if(r[j % len(r)] != -1) m[i] = min(m[i], r[j % len(r)]); } } int mn = 1000000009; for(int i = 0; i < len(r); i++){ if(r[i] != -1) mn = min(mn, r[i] - c[i]); } // cout << mn << " "; for(int i = 0; i < len(r); i++){ if(r[i] - c[i] == mn && m[i] > mn){ // cout << i << " " << m[i] << endl; v[i] = x; r[i] = -1; break; } } } // for(int i = 0; i < len(r); i++){ // cout << v[i] << " "; // } // cout << endl; }
#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...