QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#446689#6389. TopicalsndCompile Error//C++141.4kb2024-06-17 15:09:012024-06-17 15:09:01

Judging History

你现在查看的是最新测评结果

  • [2024-06-17 15:09:01]
  • 评测
  • [2024-06-17 15:09:01]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define pp pop_back
#define pb push_back
#define eb emplace_back
#define nl cout "\n"
#define sp <<" "
#define spc <<" "<<
#define ff first
#define ss second
#define r0 return 0
#define INF INT_MAX
#define mod 998244353
#define MOD 1000000007
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vs vector<string>
#define pii pair <int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define pis pair<int,string>
#define sz size()
#define pause system("pause")
#define min3(a,b,c) min(a,min(b,c))
#define all(x) (x).begin(),(x).end()
#define deb(x) cout << #x << " - " << x << endl
using namespace std;
const int N=INT_MAX*1000000;
vector <int> v;
pair <int, int> p[N];
inline void test_case(){
	int n, k;
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> p[i].ff;
	}
	for(int i=0; i<n; i++){
		cin >> p[i].ss;
	}
	sort(p, p+n);
	int sc=0;
	int ans=0;
	for(int i=0; i<n; i++){
		if(sc>=p[i].ff){
			ans++;
			sc+=p[i].ss;
		}
	}
	cout << ans;
}
signed main () {
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int T = 1;
    // cin >> T;
    while(T--) {
        test_case();
    }
    
    return 0;
}






Details

answer.code:36:20: warning: integer overflow in expression of type ‘int’ results in ‘-1000000’ [-Woverflow]
   36 | const int N=INT_MAX*1000000;
      |                    ^
answer.code:38:19: error: size ‘-1000000’ of array ‘p’ is negative
   38 | pair <int, int> p[N];
      |                   ^