답안 #1026361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1026361 2024-07-18T02:36:55 Z Mardonbekhazratov 메기 농장 (IOI22_fish) C++17
3 / 100
59 ms 10872 KB
#include "fish.h"

#include <iostream>
#include <vector>
#include <tuple>
#include <set>
#include <algorithm>
#include <map>

using namespace std;

#define ff first
#define ss second
#define ll long long

int n,m;
vector<int>x,y,w;
ll ans=0;

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
    tie(n,m,x,y,w)=tie(N,M,X,Y,W);
    bool su1=true,su2=true;
    for(int i=0;i<m;i++){
        if(x[i]%2==1) su1=false;
        if(x[i]>1) su2=false;
    }
    if(su1){for(int i=0;i<m;i++) ans+=w[i];return ans;}
    if(su2){
        vector<pair<int,int>>a,b;
        ll cur=0;
        for(int i=0;i<m;i++){
            if(x[i]) cur+=w[i],a.push_back({y[i],w[i]});
            else b.push_back({y[i],w[i]});
        }
        sort(a.begin(),a.end());
        sort(b.begin(),b.end());
        ans=cur;
        int j=0;
        for(auto [g,f]:b){
            cur+=f;
            while(j<b.size() && b[j].ff<=g) cur-=b[j].ss,j++;
            ans=max(ans,cur);
        }
        return ans;
    }
    return ans;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             while(j<b.size() && b[j].ff<=g) cur-=b[j].ss,j++;
      |                   ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 3152 KB Output is correct
2 Correct 26 ms 3920 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 52 ms 10872 KB Output is correct
6 Correct 59 ms 10848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '882019', found: '0'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '882019', found: '0'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 3152 KB Output is correct
2 Correct 26 ms 3920 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 52 ms 10872 KB Output is correct
6 Correct 59 ms 10848 KB Output is correct
7 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
8 Halted 0 ms 0 KB -