ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1522. Factory

Why is my solution WA#30?
Posted by hyman00 7 Apr 2022 19:20
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
#define rept(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,a) rept(i,0,a)
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
const int MOD=1000000007,INF=1000000000000000000;
template<typename T>inline void Mx(T &a,T b){a=max(a,b);}
template<typename T>inline void Mi(T &a,T b){a=min(a,b);}
inline int ad(int &a,int b,int c=MOD){re a=(a+b)%c;}
template<typename T>inline T read(){T a;cin>>a;re a;}
inline bool is_digit(int msk,int d){re (msk>>d)&1;}
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
struct thing{int a,b,c,id;}p[100005];
bool operator<(thing a,thing b){
    int p=a.a+b.c+max(a.b+a.c,b.a+b.b);
    int q=b.a+a.c+max(b.b+b.c,a.a+a.b);
    if(p==q)re a.a<b.a;
    re p<q;
}
int n;
void run(){
    cin>>n;
    rep(i,n)cin>>p[i].a>>p[i].b>>p[i].c,p[i].id=i+1;
    sort(p,p+n);
    int a=0,b=0,c=0;
    rep(i,n){
        a=a+p[i].a;
        b=max(a,b)+p[i].b;
        c=max(b,c)+p[i].c;
    }
    cout<<c<<"\n";
    rep(i,n)cout<<p[i].id<<" ";
    cout<<"\n";
}
signed main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(0);cout.tie(0);
//    for(int tc=read<int>();tc;tc--)
        run();
    re 0;
}