답안 #136384

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
136384 2019-07-25T08:11:51 Z dndhk Naan (JOI19_naan) C++14
29 / 100
509 ms 97144 KB
#include <bits/stdc++.h>

#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX_N = 2000;

ll N, L;
ll arr[MAX_N+1][MAX_N+1];
ll sum[MAX_N+1];

vector<pll> vt[MAX_N+1];
bool vst[MAX_N+1];

vector<pll> ans;
vector<int> ans2;

bool calc(pll a, pll b){
	a.first /= L; b.first /= L;
	a.second /= N; b.second /= N;
	return (a.first * b.second > a.second * b.first);
}

int main(){
	scanf("%lld%lld", &N, &L);
	for(int i=1; i<=N; i++){
		for(int j=1; j<=L; j++){
			scanf("%lld", &arr[i][j]);
			sum[i]+=arr[i][j];
		}
		int now = 1;
		ll S = 0;
		for(int j=1; j<=L; j++){
			while(1){
				//cout<<S<<" "<<now<<endl;
				if((S+arr[i][j]) * N <= now * sum[i]){
					break;
				}
				pll p;
				p.first = sum[i] * now - S * N + (j-1) * N * arr[i][j];
				p.second = N * arr[i][j];
				vt[i].pb(p);
				//cout<<p.first<<" "<<p.second<<endl;
				now++;
			}
			S += arr[i][j];
		}
	}
	for(int i=0; i<N-1; i++){
		pll prv = {L, 0};
		int idx=0;
		for(int j=1; j<=N; j++){
			//cout<<prv.first<<" "<<prv.second<<" "<<vt[j][i].first<<" "<<vt[j][i].second<<endl;
			if(!vst[j] && calc(prv, vt[j][i])){
				idx = j; prv = vt[j][i];
			}
		}
		//cout<<idx<<endl;
		vst[idx] = true;
		ans.pb(prv);
		ans2.pb(idx);
	}
	for(int j=1; j<=N; j++){
		if(!vst[j]){
			ans2.pb(j);
			break;
		}
	}
	for(int i=0; i<ans.size(); i++){
		printf("%lld %lld\n", ans[i].first, ans[i].second);
	}
	for(int i=0; i<ans2.size(); i++){
		printf("%d ", ans2[i]);
	}
	return 0;
}

Compilation message

naan.cpp: In function 'int main()':
naan.cpp:87:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<ans.size(); i++){
               ~^~~~~~~~~~~
naan.cpp:90:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<ans2.size(); i++){
               ~^~~~~~~~~~~~
naan.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &N, &L);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
naan.cpp:46:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld", &arr[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 508 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 504 KB Output is correct
19 Correct 3 ms 504 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 3 ms 504 KB Output is correct
22 Correct 3 ms 504 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 504 KB Output is correct
25 Correct 3 ms 372 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 504 KB Output is correct
19 Correct 3 ms 504 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 3 ms 504 KB Output is correct
22 Correct 3 ms 504 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 5 ms 504 KB Output is correct
25 Correct 3 ms 504 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 508 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 3 ms 504 KB Output is correct
32 Correct 3 ms 504 KB Output is correct
33 Correct 3 ms 504 KB Output is correct
34 Correct 3 ms 504 KB Output is correct
35 Correct 3 ms 504 KB Output is correct
36 Correct 3 ms 504 KB Output is correct
37 Correct 3 ms 504 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 3 ms 504 KB Output is correct
40 Correct 3 ms 372 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 3 ms 504 KB Output is correct
43 Correct 65 ms 13432 KB Output is correct
44 Correct 392 ms 64068 KB Output is correct
45 Correct 220 ms 28920 KB Output is correct
46 Correct 32 ms 3576 KB Output is correct
47 Correct 272 ms 39264 KB Output is correct
48 Correct 316 ms 76792 KB Output is correct
49 Correct 105 ms 23008 KB Output is correct
50 Correct 497 ms 97144 KB Output is correct
51 Correct 244 ms 41592 KB Output is correct
52 Correct 509 ms 87160 KB Output is correct
53 Correct 409 ms 81272 KB Output is correct
54 Correct 3 ms 504 KB Output is correct
55 Correct 149 ms 44280 KB Output is correct
56 Incorrect 322 ms 56416 KB X_i is not increasing
57 Halted 0 ms 0 KB -