# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
153002 | 2019-09-11T09:29:47 Z | oolimry | Naan (JOI19_naan) | C++14 | 2 ms | 504 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<long long, long long> ii; bool great(ii a, ii b){ long long wa = a.first / a.second; long long wb = b.first / b.second; if(wa == wb){ return a.first * b.second < a.second * b.first; } return wa < wb; //is b greater than a } int main(){ freopen("i.txt","r",stdin); cin.tie(0); long long n, l; cin >> n >> l; long long arr[n][l]; long long sums[n]; fill(sums,sums+n,0); for(long long i = 0;i < n;i++) for(long long j = 0;j < l;j++){ cin >> arr[i][j]; sums[i] += arr[i][j]; arr[i][j] *= n; } long long pre[n][l]; for(long long i = 0;i < n;i++) for(long long j = 0;j < l;j++){ pre[i][j] = arr[i][j]; if(j != 0) pre[i][j] += pre[i][j-1]; } bool used[n]; fill(used,used+n,false); vector<long long> order; for(long long r = 0;r < n;r++){ ii minfrac = ii(102344213,1); int mini; for(long long i = 0;i < n;i++){ if(used[i]) continue; long long need = (r+1) * sums[i]; long long x = upper_bound(pre[i],pre[i]+l,need) - pre[i]; ii frac; frac.second = arr[i][x]; frac.first = need; if(x != 0) frac.first -= pre[i][x-1]; frac.first += x * frac.second; if(great(frac,minfrac)){ minfrac = frac; mini = i; } } if(r != n-1) cout << minfrac.first << " " << minfrac.second << "\n"; used[mini] = true; order.push_back(mini); } for(int i = 0;i < n;i++){ cout << order[i] + 1 << " "; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 376 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |