Submission #1867618


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const long long INF = 9223372000000000000/2145;
//static const int INF = 1000010000;
//static const int NIL = -1;
//static const int MOD = 1000000007;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
//#define int ll

signed main(){
    bool dpw[3145]={},dps[3145]={};
    dpw[0] = dps[0] = 1;
    int a,b,c,d,e,f;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    a*=100,b*=100;
    double p = double(e)/double(100+e);

    for(int i=0;i<3145;i++){
        if(dpw[i]){
            if(i+a<=f) dpw[i+a] = 1;
            if(i+b<=f) dpw[i+b] = 1;
        }
        if(dps[i]){
            if(i+c<=f) dps[i+c] = 1;
            if(i+d<=f) dps[i+d] = 1;
        }
    }

    double ans=0;
    int s=a,t=0;
    for(int i=0;i<=f;i++){
        if(dpw[i]){
            for(int j=0;i+j<=f;j++){
                if(dps[j]){
                    //printf("%d %d\n",i,j);
                    double tmp = double(j)/double(i+j);
                    if(tmp>ans&&p>=tmp){
                        s = i+j;
                        t = j;
                        ans = tmp;
                    }
                }
            }
        }
    }

    printf("%d %d\n",s,t);
    return 0;
}

Submission Info

Submission Time
Task C - Sugar Water
User r67pr
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1996 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:35:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
                                            ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 12
Set Name Test Cases
Sample subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
Case Name Status Exec Time Memory
01.txt AC 1 ms 256 KB
02.txt AC 1 ms 256 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 1 ms 256 KB
06.txt AC 1 ms 256 KB
07.txt AC 1 ms 256 KB
08.txt AC 1 ms 256 KB
09.txt AC 1 ms 256 KB
subtask0_0.txt AC 1 ms 256 KB
subtask0_1.txt AC 1 ms 256 KB
subtask0_2.txt AC 1 ms 256 KB