제출 #1273479

#제출 시각아이디문제언어결과실행 시간메모리
1273479SmuggingSpunPod starim krovovima (COCI20_psk)C++20
50 / 50
1 ms572 KiB
#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
	int n;
	cin >> n;
	vector<int>t(n);
	ll Z = 0;
	for(int i = 0; i < n; i++){
		int z;
		cin >> z >> t[i];
		Z += z;
	}
	vector<int>p(n);
	iota(p.begin(), p.end(), 0);
	sort(p.begin(), p.end(), [&] (int i, int j){
		return t[i] > t[j];
	});
	for(int i = 0; i < n; i++){
		if(Z <= t[p[i]]){
			t[p[i]] = Z;
			cout << n - i - 1 << "\n";
			for(int j = i + 1; j < n; j++){
				t[p[j]] = 0;
			}
			break;
		}
		Z -= t[p[i]];
	}
	for(int& x : t){
		cout << x << " ";
	}
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:8:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...