/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 372.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 1ms 516.0 KiB
#4 Accepted 1ms 488.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;

#define pb push_back
#define pob pop_back()
#define mp make_pair
#define sz size()
#define ff first
#define ss second
#define PI 3.14159265359
#define M1 ll(998244353)
#define M2 ll(1000000007)
#define pres(x) cout<<fixed; cout<<setprecision(x);
#define out(x) cout<<x<<endl;

ll gcd(ll a, ll b) {
    if (b > a) {return gcd(b, a);}
    if (b == 0) {return a;}
    return gcd(b, a % b);
}
int power(int a,int b){
    int ans=1;
    while(b!=0){
        if(b&1){ans=(ans*a)%M2;b--;}
        a=(a*a)%M2;b/=2;
    }
    return ans%M2;
}
ll expo(ll a, ll b, ll mod) {
    ll res = 1; 
    while (b > 0) {
        if (b & 1) res = (res * a) % mod;
        a = (a * a) % mod; 
        b = b >> 1;
    } 
    return res;
}
int invmod(int n){
    int ans=1;
    ans=power(n,M2-2);
    return ans;
}
int lcm(int a,int b){
    int g=gcd(a,b);
    a/=g;a*=b;
    return a;
}
ll nCr(int n, int r){
    if(r>n) return 0;
    if(r==n || r==0) return 1;
    double sum = 1;
    for(int i = 1; i <= r; i++){
        sum = sum * (n - r + i) / i;
    }
    return (long long)sum;
}
ll mrginv(vi &v,int l,int mid,int r){
    ll val=0;
    for(int i=mid;i<=r;i++){
        int it=upper_bound(v.begin()+l,v.begin()+mid,v[i])-v.begin()-l;
        val+=ll((mid-l)-it);
    }
    int i=l,j=mid,k=0;
    vi tmp(r-l+1);
    while(i<mid && j<(r+1)){
        if(v[i]<v[j]) tmp[k++]=v[i++];
        else tmp[k++]=v[j++];
    }
    while(i<mid) tmp[k++]=v[i++];
    while(j<r+1) tmp[k++]=v[j++];
    for(int i=l;i<=r;i++) v[i]=tmp[i-l];
    return val;
}
ll cntinv(vi &v,int l,int r){
    if(l==r) return 0;
    int n=r-l+1;
    int mid=l+n/2;
    return cntinv(v,l,mid-1)+cntinv(v,mid,r)+mrginv(v,l,mid,r);
}

void solve(){
    int n;
    cin>>n;
    if(n%3==0) cout<<n/3<<endl;
    else if(n%3==2) cout<<(n/3)+1<<endl;
    else cout<<(n-3)/3+2<<endl;
    return;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1106 too easy or three easy
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-05 06:08:28
Judged At
2024-11-11 02:40:31
Judged By
Score
100
Total Time
1ms
Peak Memory
540.0 KiB